Перейти к контенту
I have run into a strange problem with Postgres 9 on Mac OS X, I have the following statement which works on Windows Postgres but on on Mac OS postgres
CREATE DOMAIN pkey_domain AS SERIAL PRIMARY KEY;
returns
ERROR: type «serial» does not exist
*** Error ***
ERROR: type «serial» does not exist
SQL state: 42704
SERIAL is a data type that is supported by postgres why am I not able to create a Domain with it? Does the deafult installer on the Mac not create the type?
asked Jul 5, 2011 at 9:40
1
Serial isn’t really a type, it is a kind of macro that creates the sequence for you, sets the default value of the column, etc. It is not referenced in pg_type. So you can’t use it like this.
answered Jul 5, 2011 at 11:00
bobfluxbobflux
10.9k3 gold badges26 silver badges26 bronze badges
4
Issue Description
I getting error type "serial" does not exist
What are you doing?
// postgres.js const sql = new Sequelize(db, username, password, { host, port, dialect: 'postgres', dialectOptions: { ssl: false }, logging: false, define: { timestamps: false, charset: 'utf8' } }); sql .sync({ alter: true }) .catch((err) => logger.error( `[PostgreSQL]: Unable to the sync tables from server; ${err.message} ${err.parent && err.parent.sql ? '; with these SQL Query' : ''} ${err.parent && err.parent.sql ? 'n' : ''} ${(err.parent && err.parent.sql) || ''}` ) ) .then(() => sql.authenticate()) .then(() => logger.info('[PostgreSQL]: Connection has been established successfully.') ) .catch((err) => logger.error( `[PostgreSQL]: Unable to connect to the database ${err.message}` ) ); export default sql; // the file error happening import DataTypes from 'sequelize'; import { v4 as uuidv4 } from 'uuid'; import sequelize from '../connections/postgres.js'; export default sequelize.define( 'Order', { id: { type: DataTypes.UUID, defaultValue() { return uuidv4(); }, primaryKey: true }, seqNo: { type: DataTypes.INTEGER, autoIncrement: true }, description: { type: DataTypes.STRING, allowNull: false } }, { freezeTableName: true, // define the table's name tableName: 'orders' } );
What do you expect to happen?
Successfully sync, altering table
What is actually happening?
[PostgreSQL]: Unable to the sync tables from server;
type "serial" does not exist
; with these SQL Query
ALTER TABLE "orders" ALTER COLUMN "seqNo" DROP NOT NULL;ALTER TABLE "orders" ALTER COLUMN "seqNo" DROP DEFAULT;ALTER TABLE "orders" ALTER COLUMN "seqNo" TYPE SERIAL;
[PostgreSQL]: Connection has been established successfully.
Additional context
Add any other context or screenshots about the feature request here.
Environment
- Sequelize version: v6.5.0
- Node.js version: v15.13.0
- Operating System: macOS Catalina 10.15.7
- If TypeScript related: TypeScript version: XXX
Issue Template Checklist
How does this problem relate to dialects?
- I think this problem happens regardless of the dialect.
- I think this problem happens only for the following dialect(s):
- I don’t know, I was using Postgres, with
pg@8.5.1
andpg-hstore@2.x
versions and database versionpostgres@12
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I don’t know how to start, I would need guidance.
- No, I don’t have the time, although I believe I could do it if I had the time…
- No, I don’t have the time and I wouldn’t even know how to start.
jambas92 59 / 58 / 16 Регистрация: 18.11.2010 Сообщений: 315 |
||||
1 |
||||
10.03.2013, 19:31. Показов 4407. Ответов 3 Метки нет (Все метки)
Здравствуйте! Хочу создать id как primary key и чтобы был auto increment, в доке пишется что стоит просто написать SERIAL и все заработает, но написав выходит такая ошибка: ОК, расписал я этот SERIAL как:
выходит такая ошибка: использую Netbeans 7.2. Не знаю как решить эту проблему.
__________________ 0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
10.03.2013, 19:31 |
Ответы с готовыми решениями:
create table schedule ( serial profile (bluetooth gps) — как работает? Serial to Wi-Fi Serial key 3 |
grgdvo 1184 / 914 / 367 Регистрация: 02.09.2012 Сообщений: 2,785 |
||||
11.03.2013, 15:22 |
2 |
|||
Может проблема в NetBeans?
1 |
59 / 58 / 16 Регистрация: 18.11.2010 Сообщений: 315 |
|
11.03.2013, 18:27 [ТС] |
3 |
grgdvo, в pgadmine все работает грамотно. просто хотелось не отходя от кассы все в одном месте делать. 0 |
1184 / 914 / 367 Регистрация: 02.09.2012 Сообщений: 2,785 |
|
12.03.2013, 14:57 |
4 |
Я вот еще раз пересмотрел первый пост, почитал про NetBeans. 1 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
12.03.2013, 14:57 |
Помогаю со студенческими работами здесь Proteus serial Можно ли в протее подключить эмулятор терминала (внешний или встроенный) в… Qt и serial порт Эхо на Serial QT serial port пытаюсь заставить работать ком порт в QT для начала решил попробовать простой… Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 4 |
Ответ на:
комментарий
от pi11 01.11.17 00:13:34 MSK
Я к тому, что — создаешь секвинс, потом alter column set default nexval(‘твой_секвинс’);
вот тебе и поле сериал стало.
pi11 ★★★★★
(01.11.17 00:20:04 MSK)
- Показать ответы
- Ссылка
Ответ на:
комментарий
от pi11 01.11.17 00:20:04 MSK
спасибо, понятно.
cetjs2 ★★★★★
(01.11.17 00:23:27 MSK)
- Ссылка
Ответ на:
комментарий
от pi11 01.11.17 00:20:04 MSK
Ещё не забыть сделать столбец таблицы владельцем последовательности.
- Ссылка
В postgresql 10 уже стоит использовать тип identity/bigidentity — это улучшенный serial/bigserial.
dmitry_vk ★★★
(01.11.17 12:26:45 MSK)
- Показать ответ
- Ссылка
Ответ на:
комментарий
от dmitry_vk 01.11.17 12:26:45 MSK
Ответ на:
комментарий
от cetjs2 01.11.17 15:19:04 MSK
Ответ на:
комментарий
от anonymous 01.11.17 15:56:39 MSK
Ответ на:
комментарий
от anonymous 01.11.17 15:56:39 MSK
Ответ на:
комментарий
от cetjs2 01.11.17 15:19:04 MSK
Ответ на:
комментарий
от slovazap 01.11.17 17:00:23 MSK
Ответ на:
комментарий
от anonymous 02.11.17 00:01:30 MSK
Ответ на:
комментарий
от slovazap 02.11.17 12:53:42 MSK
Ну пруфани проблемы с пакетами из репозитория разрабов профпригодник ты наш, говорить все горазды.
anonymous
(02.11.17 16:21:28 MSK)
- Ссылка
Ответ на:
комментарий
от slovazap 02.11.17 12:53:42 MSK
это отличный совет.
если чета начнет глючить,
в рассылке первым делом посоветуют поставить вместо левых пакетов из дистра, официальные, потом уже дальше будут разбираться.
этоже касается nginx и node.
drsm ★★
(02.11.17 19:47:02 MSK)
- Показать ответ
- Ссылка
Ответ на:
комментарий
от drsm 02.11.17 19:47:02 MSK
Поставить пакеты от авторов могут советовать только абсолютно безграмотные люди, это совет уровня «выключить и снова включить». Такие же безграмотные люди пишут эти пакеты, поскольку мантейнерами дистрибутива они не являются и от пакетирования очень далеки, пакет не проходит никакого review и QA, и также разрабатывается отдельно от основного репозитория, поэтому обновление основного репозитория может его в любой момент сломать. Я наступал в проблемы с «официальными» пакетами от авторов много раз, и держаться от них подальше — единственный действительно хороший совет.
slovazap ★★★★★
(02.11.17 21:21:07 MSK)
- Ссылка
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Я столкнулся со странной проблемой с Postgres 9 в Mac OS X. У меня есть следующее утверждение, которое работает в Windows Postgres, но в Mac OS postgres.
СОЗДАТЬ ДОМЕН pkey_domain КАК ПОСЛЕДОВАТЕЛЬНЫЙ ПЕРВИЧНЫЙ КЛЮЧ;
Возвращает
ОШИБКА: тип «серийный» не существует
Ошибка ***
ОШИБКА: тип «серийный» не существует Состояние SQL: 42704
SERIAL — это тип данных, поддерживаемый postgres, почему я не могу создать с ним домен? Установщик по умолчанию на Mac не создает тип?
1 ответы
Serial на самом деле не является типом, это своего рода макрос, который создает для вас последовательность, устанавливает значение столбца по умолчанию и т. д. Он не упоминается в pg_type. Таким образом, вы не можете использовать его так.
Создан 05 июля ’11, 12:07
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
postgresql
or задайте свой вопрос.
I am having some issues with serial type lately. Problem reflects in some changes in the schema file that cannot be loaded later on, failing wiht exception:
PG::UndefinedObject: ERROR: type "serial" does not exist LINE 1: SELECT 'serial'::regtype::oid ^ /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `async_exec' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `block (2 levels) in query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:60:in `block in query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:59:in `query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:70:in `query_value' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/quoting.rb:81:in `lookup_cast_type' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/quoting.rb:114:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/quoting.rb:71:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:17:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:103:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:42:in `block in add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:41:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/schema_creation.rb:10:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:34:in `visit_ColumnDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `block in visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `map' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:48:in `block in visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:47:in `visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:288:in `create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:28:in `block in create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:27:in `create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:849:in `block in method_missing' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:818:in `block in say_with_time' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:818:in `say_with_time' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:838:in `method_missing' /home/broisatse/work/Hubbado/hubbadoproto/db/schema.rb:20:in `block in <main>' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:48:in `instance_eval' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:48:in `define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:44:in `define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/schema.rb:7:in `block in define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/schema.rb:6:in `define' /home/broisatse/work/Hubbado/hubbadoproto/db/schema.rb:13:in `<main>' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:286:in `block in load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:286:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:233:in `load_schema' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:255:in `block in load_schema_current' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:254:in `load_schema_current' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/railties/databases.rake:248:in `block (3 levels) in <main>' /home/broisatse/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Below is bit of the schema without schema_plus_pg_indexes (first table — backtrace points to this create_table call):
create_table "acquired_certifications", id: :serial, force: :cascade do |t| t.date "date" t.date "expires" t.datetime "created_at" t.datetime "updated_at" t.integer "contractor_id" t.integer "certification_id" t.string "reference" t.index ["certification_id"], name: "index_acquired_certifications_on_certification_id" t.index ["contractor_id"], name: "index_acquired_certifications_on_contractor_id" end
create_table "acquired_certifications", id: :serial, default: %q{nextval('acquired_certifications_id_seq'::regclass)}, force: :cascade do |t| t.date "date" t.date "expires" t.datetime "created_at" t.datetime "updated_at" t.integer "contractor_id", :index=>{:name=>"index_acquired_certifications_on_contractor_id"} t.integer "certification_id", :index=>{:name=>"index_acquired_certifications_on_certification_id"} t.string "reference" end
I am having some issues with serial type lately. Problem reflects in some changes in the schema file that cannot be loaded later on, failing wiht exception:
PG::UndefinedObject: ERROR: type "serial" does not exist LINE 1: SELECT 'serial'::regtype::oid ^ /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `async_exec' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `block (2 levels) in query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:60:in `block in query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:59:in `query' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:70:in `query_value' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/quoting.rb:81:in `lookup_cast_type' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/quoting.rb:114:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/quoting.rb:71:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:17:in `quote_default_expression' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:103:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:42:in `block in add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:41:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/postgresql/schema_creation.rb:10:in `add_column_options!' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:34:in `visit_ColumnDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `block in visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `map' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:45:in `visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:48:in `block in visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:47:in `visit_TableDefinition' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:288:in `create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:28:in `block in create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/connection_adapters/abstract_adapter.rb:27:in `create_table' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:849:in `block in method_missing' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:818:in `block in say_with_time' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:818:in `say_with_time' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/migration.rb:838:in `method_missing' /home/broisatse/work/Hubbado/hubbadoproto/db/schema.rb:20:in `block in <main>' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:48:in `instance_eval' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:48:in `define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/schema.rb:44:in `define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/schema.rb:7:in `block in define' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:54:in `call_implementation' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:84:in `_modware_continue' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:76:in `_modware_call' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:43:in `execute' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/modware-0.1.3/lib/modware/stack.rb:19:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_monkey-2.1.5/lib/schema_monkey/stack.rb:34:in `start' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/schema_plus_core-2.1.1/lib/schema_plus/core/active_record/schema.rb:6:in `define' /home/broisatse/work/Hubbado/hubbadoproto/db/schema.rb:13:in `<main>' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:286:in `block in load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:258:in `load_dependency' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activesupport-5.1.3/lib/active_support/dependencies.rb:286:in `load' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:233:in `load_schema' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:255:in `block in load_schema_current' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:254:in `load_schema_current' /home/broisatse/.rvm/gems/ruby-2.4.1/gems/activerecord-5.1.3/lib/active_record/railties/databases.rake:248:in `block (3 levels) in <main>' /home/broisatse/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Below is bit of the schema without schema_plus_pg_indexes (first table — backtrace points to this create_table call):
create_table "acquired_certifications", id: :serial, force: :cascade do |t| t.date "date" t.date "expires" t.datetime "created_at" t.datetime "updated_at" t.integer "contractor_id" t.integer "certification_id" t.string "reference" t.index ["certification_id"], name: "index_acquired_certifications_on_certification_id" t.index ["contractor_id"], name: "index_acquired_certifications_on_contractor_id" end
create_table "acquired_certifications", id: :serial, default: %q{nextval('acquired_certifications_id_seq'::regclass)}, force: :cascade do |t| t.date "date" t.date "expires" t.datetime "created_at" t.datetime "updated_at" t.integer "contractor_id", :index=>{:name=>"index_acquired_certifications_on_contractor_id"} t.integer "certification_id", :index=>{:name=>"index_acquired_certifications_on_certification_id"} t.string "reference" end
I have run into a strange problem with Postgres 9 on Mac OS X, I have the following statement which works on Windows Postgres but on on Mac OS postgres
CREATE DOMAIN pkey_domain AS SERIAL PRIMARY KEY;
returns
ERROR: type «serial» does not exist
*** Error ***
ERROR: type «serial» does not exist
SQL state: 42704
SERIAL is a data type that is supported by postgres why am I not able to create a Domain with it? Does the deafult installer on the Mac not create the type?
asked Jul 5, 2011 at 9:40
1
Serial isn’t really a type, it is a kind of macro that creates the sequence for you, sets the default value of the column, etc. It is not referenced in pg_type. So you can’t use it like this.
answered Jul 5, 2011 at 11:00
bobfluxbobflux
11.1k3 gold badges26 silver badges27 bronze badges
4
Есть таблица с заполненными данными:
CREATE TABLE "Виплата"
(
old integer NOT NULL,
"Код_договору" integer,
"Дата" timestamp(0) without time zone,
"Сума_виплат" text,
"Оплата" boolean,
"Код" integer,
CONSTRAINT "Виплата_pkey" PRIMARY KEY (old)
)
WITH (
OIDS=FALSE
);
ALTER TABLE "Виплата"
OWNER TO postgres;
Обязательно нужно изменить тип колонки «Код» на serial! Обычным
ALTER: ALTER TABLE "Виплата" ALTER COLUMN "Код" type serial;
не получается это сделать, потому что serial не тип ERROR: type "serial" does not exist !
Но сделать это очень нужно.
Каким способом можно это реализовать ?
Issue Description
I getting error type "serial" does not exist
What are you doing?
// postgres.js const sql = new Sequelize(db, username, password, { host, port, dialect: 'postgres', dialectOptions: { ssl: false }, logging: false, define: { timestamps: false, charset: 'utf8' } }); sql .sync({ alter: true }) .catch((err) => logger.error( `[PostgreSQL]: Unable to the sync tables from server; ${err.message} ${err.parent && err.parent.sql ? '; with these SQL Query' : ''} ${err.parent && err.parent.sql ? 'n' : ''} ${(err.parent && err.parent.sql) || ''}` ) ) .then(() => sql.authenticate()) .then(() => logger.info('[PostgreSQL]: Connection has been established successfully.') ) .catch((err) => logger.error( `[PostgreSQL]: Unable to connect to the database ${err.message}` ) ); export default sql; // the file error happening import DataTypes from 'sequelize'; import { v4 as uuidv4 } from 'uuid'; import sequelize from '../connections/postgres.js'; export default sequelize.define( 'Order', { id: { type: DataTypes.UUID, defaultValue() { return uuidv4(); }, primaryKey: true }, seqNo: { type: DataTypes.INTEGER, autoIncrement: true }, description: { type: DataTypes.STRING, allowNull: false } }, { freezeTableName: true, // define the table's name tableName: 'orders' } );
What do you expect to happen?
Successfully sync, altering table
What is actually happening?
[PostgreSQL]: Unable to the sync tables from server;
type "serial" does not exist
; with these SQL Query
ALTER TABLE "orders" ALTER COLUMN "seqNo" DROP NOT NULL;ALTER TABLE "orders" ALTER COLUMN "seqNo" DROP DEFAULT;ALTER TABLE "orders" ALTER COLUMN "seqNo" TYPE SERIAL;
[PostgreSQL]: Connection has been established successfully.
Additional context
Add any other context or screenshots about the feature request here.
Environment
- Sequelize version: v6.5.0
- Node.js version: v15.13.0
- Operating System: macOS Catalina 10.15.7
- If TypeScript related: TypeScript version: XXX
Issue Template Checklist
How does this problem relate to dialects?
- I think this problem happens regardless of the dialect.
- I think this problem happens only for the following dialect(s):
- I don’t know, I was using Postgres, with
pg@8.5.1
andpg-hstore@2.x
versions and database versionpostgres@12
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I don’t know how to start, I would need guidance.
- No, I don’t have the time, although I believe I could do it if I had the time…
- No, I don’t have the time and I wouldn’t even know how to start.
Problem
When autosync is enabled the schema is synced correctly on the first run, when the application is restarted it will fail with the following error.
QueryFailedError: type "serial" does not exist
The following entity was used.
@Entity()
class testEntity {
@PrimaryGeneratedColumn()
public sourceInventoryId: number;
@Column({ type: "serial" })
public testColumn: number;
}
Possible cause
It tries to execute the following query ALTER TABLE "test_entity" ALTER COLUMN "sourceInventoryId" TYPE serial
. This fails because serial
is not supported in ALTER COLUMN
statements.
Possible solution
Check the current type of the column, if it is already integer with a sequence don’t try to change it. If it already exists, the only solution is to delete the column (don’t think this is something we want) or to fail with an exception.
Another solution is not to support serial
like types on Column
decorators. This then can be solved by introducing a GeneratedColumn
decorator similar to PrimaryGeneratedColumn
(which already does not support a serial
type).
database: postgres 9.6
typeorm version: 0.1.0-alpha.34
typescript: 2.4.2
Ответ на:
комментарий
от pi11 01.11.17 00:13:34 MSK
Я к тому, что — создаешь секвинс, потом alter column set default nexval(‘твой_секвинс’);
вот тебе и поле сериал стало.
pi11 ★★★★★
(01.11.17 00:20:04 MSK)
- Показать ответы
- Ссылка
Ответ на:
комментарий
от pi11 01.11.17 00:20:04 MSK
спасибо, понятно.
cetjs2 ★★★★★
(01.11.17 00:23:27 MSK)
- Ссылка
Ответ на:
комментарий
от pi11 01.11.17 00:20:04 MSK
Ещё не забыть сделать столбец таблицы владельцем последовательности.
- Ссылка
В postgresql 10 уже стоит использовать тип identity/bigidentity — это улучшенный serial/bigserial.
dmitry_vk ★★★
(01.11.17 12:26:45 MSK)
- Показать ответ
- Ссылка
Ответ на:
комментарий
от dmitry_vk 01.11.17 12:26:45 MSK
Ответ на:
комментарий
от cetjs2 01.11.17 15:19:04 MSK
Ответ на:
комментарий
от anonymous 01.11.17 15:56:39 MSK
Ответ на:
комментарий
от anonymous 01.11.17 15:56:39 MSK
Ответ на:
комментарий
от cetjs2 01.11.17 15:19:04 MSK
Ответ на:
комментарий
от slovazap 01.11.17 17:00:23 MSK
Ответ на:
комментарий
от anonymous 02.11.17 00:01:30 MSK
Ответ на:
комментарий
от slovazap 02.11.17 12:53:42 MSK
Ну пруфани проблемы с пакетами из репозитория разрабов профпригодник ты наш, говорить все горазды.
anonymous
(02.11.17 16:21:28 MSK)
- Ссылка
Ответ на:
комментарий
от slovazap 02.11.17 12:53:42 MSK
это отличный совет.
если чета начнет глючить,
в рассылке первым делом посоветуют поставить вместо левых пакетов из дистра, официальные, потом уже дальше будут разбираться.
этоже касается nginx и node.
drsm ★★
(02.11.17 19:47:02 MSK)
- Показать ответ
- Ссылка
Ответ на:
комментарий
от drsm 02.11.17 19:47:02 MSK
Поставить пакеты от авторов могут советовать только абсолютно безграмотные люди, это совет уровня «выключить и снова включить». Такие же безграмотные люди пишут эти пакеты, поскольку мантейнерами дистрибутива они не являются и от пакетирования очень далеки, пакет не проходит никакого review и QA, и также разрабатывается отдельно от основного репозитория, поэтому обновление основного репозитория может его в любой момент сломать. Я наступал в проблемы с «официальными» пакетами от авторов много раз, и держаться от них подальше — единственный действительно хороший совет.
slovazap ★★★★★
(02.11.17 21:21:07 MSK)
- Ссылка
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
jambas92 59 / 58 / 16 Регистрация: 18.11.2010 Сообщений: 315 |
||||
1 |
||||
10.03.2013, 19:31. Показов 4821. Ответов 3 Метки нет (Все метки)
Здравствуйте! Хочу создать id как primary key и чтобы был auto increment, в доке пишется что стоит просто написать SERIAL и все заработает, но написав выходит такая ошибка: ОК, расписал я этот SERIAL как:
выходит такая ошибка: использую Netbeans 7.2. Не знаю как решить эту проблему.
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
10.03.2013, 19:31 |
Ответы с готовыми решениями:
create table schedule ( serial profile (bluetooth gps) — как работает? Serial to Wi-Fi Serial key 3 |
grgdvo 1213 / 938 / 373 Регистрация: 02.09.2012 Сообщений: 2,859 |
||||
11.03.2013, 15:22 |
2 |
|||
Может проблема в NetBeans?
1 |
59 / 58 / 16 Регистрация: 18.11.2010 Сообщений: 315 |
|
11.03.2013, 18:27 [ТС] |
3 |
grgdvo, в pgadmine все работает грамотно. просто хотелось не отходя от кассы все в одном месте делать.
0 |
1213 / 938 / 373 Регистрация: 02.09.2012 Сообщений: 2,859 |
|
12.03.2013, 14:57 |
4 |
Я вот еще раз пересмотрел первый пост, почитал про NetBeans.
1 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
12.03.2013, 14:57 |
Помогаю со студенческими работами здесь Proteus serial Можно ли в протее подключить эмулятор терминала (внешний или встроенный) в… Qt и serial порт Эхо на Serial QT serial port пытаюсь заставить работать ком порт в QT для начала решил попробовать простой… Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 4 |
Я хочу изменить тип данных столбца из целого в последовательный
ALTER TABLE "TestTable" ALTER COLUMN "ID" TYPE serial ;
но он может измениться для чего угодно, кроме серийного! я получил эту ошибку
ОШИБКА: тип «serial» не существует ********** Ошибка **********
ОШИБКА: тип «serial» не существует Состояние SQL: 42704
есть ли способ решить проблему? заранее спасибо
Я столкнулся со странной проблемой с Postgres 9 на Mac OS X, у меня есть следующее утверждение, которое работает на Windows Postgres, но на Mac OS Postgres
CREATE DOMAIN pkey_domain КАК СЕРИЙНЫЙ ПЕРВИЧНЫЙ КЛЮЧ;
возвращается
ОШИБКА: тип «серийный» не существует
*** Ошибка ** *
ОШИБКА: тип «serial» не существует Состояние SQL: 42704
SERIAL — это тип данных, который поддерживается postgres. Почему я не могу создать домен с его помощью? Разве установщик по умолчанию на Mac не создает тип?