-
Notifications
You must be signed in to change notification settings - Fork 697
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
Support sequences in SQL Server #1164
Comments
Not to say that Exposed shouldn't have its sights set on covering the supported DBMS's comprehensively, sequences and all, but to solve your problem, is there a reason why the standard identity column is not appropriate in your scenario?
That's idiomatic for SQL Server. I'd only use a sequence if I needed uniqueness across >1 table. Other qns:
|
Changing type from As I mentioned, I tried to solve this problem by defining my own Another fact is, that
I made a mistake in
|
I wonder if lines 95 & 96 of
Only the dialect for Oracle overrides the default value of |
You are right. Sequences works only with Oracle, but implementation is limited only for one(first) sequence column in defined (see this row). |
I've made changes and now sequences should work find with SQL Server, but please note that SQLServer jdbc driver doesn't support returning generated values for sequences (check the issue) that means it wont be possible to use |
…ects JetBrains#492 Support sequences in SQL Server JetBrains#1164 Sequence is not used when specifying via autoIncrement JetBrains#1209
I ran into an issue when inserting row into table with SQL Server.
My table definition:
Sequence
persons_seq
exists in my db schema.When I try to insert row without specifying
id
column, I got an error:com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'id', table 'persons'; column does not allow nulls. INSERT fails.
**Solution using sequence definition: **
I tried to create own sequence as defined there
During this insert, I get an error:
Unexpected value of type Long: NEXT VALUE FOR seq_name of org.jetbrains.exposed.sql.NextVal.LongNextVal
Solution using
NEXT VALUE FOR
Another solution is to use
NEXT VALUE FOR persons_seq
in insert statement - similar implementation like usesOracleDialect.kt
there.I think that Exposed should support both solutions, using
Sequence()
and alsoNEXT VALUE FOR
Workaround
Possible workaround is to call custom query
SELECT NEXT VALUE FOR persons_seq AS 'seq_no'
that increments sequence value and returns the old value (in MSSQL) and then assign this value in InsertStatement, but I think this is not a good solution.The text was updated successfully, but these errors were encountered: