Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres - insert_returning = false combined with no sequence for :id fails #716

Closed
bcotton opened this issue Mar 21, 2016 · 0 comments
Closed
Labels

Comments

@bcotton
Copy link

bcotton commented Mar 21, 2016

activerecord-jdbc-adapter 1.3.20
jruby-9.0.5.0
postgres 9.5

Running with
insert_returning = false
(for pg_partman and insertion triggers related to #709) generates invalid SQL:

Trying to create a model with the :id column provided (type date, no sequence on the :id column)

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: invalid name syntax
  Position: 16: SELECT currval('"date_dimension"_id_seq')
arjdbc/jdbc/RubyJdbcConnection.java:888:in `execute_query'

When I change the regex on extract_table_ref_from_insert_sql to

sql[/into\s+\"([^\(\"]*).*values\s*\(/i]

to dig into the escaped quotes then I get:

ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: relation "date_dimension_id_seq" does not exist
  Position: 16: SELECT currval('date_dimension_id_seq')
arjdbc/jdbc/RubyJdbcConnection.java:888:in `execute_query'

It should not be trying to get the next value from the sequence when the :id value is provided. This works fine under MRI


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants