Fix nextval for sequence from outer schema#172
Fix nextval for sequence from outer schema#172andrey-mokhov wants to merge 1 commit intozendframework:masterfrom andrey-mokhov:patch-1
Conversation
When sequence located in outer schema or sequenceName contain quote symbols, method nextSequenceId can't fetch next id, throw exception. For example:
```sql
SELECT nextval('"test.check_sequence_id_seq"');
```
This solution allow fix it
|
In any way related to #162 ? |
|
#162 useful, when sequense name is known. But if not? |
|
This is a very good idea. Thanks for pointing out that flaw. Does bring up a further problem, involving a choice for where does the sequence name come from in Table Gateway. I had a client which did not have sequences always tied to a table in the form of a SERIAL clause, which would create implicit sequences that your changelist helps to locate. They prefer to manually request from the sequence each time and allocate it to column as they see fit. Secondly, sequences are not always used for PK columns. There can be a sequence for primary key, sure, but some schema design patters use multiple sequences per table, sometimes one sequence across multiple tables. Simplest example to think of is recept ID. If have multiple tables for order types, each one will have one own sequence for order ID, then another shared sequence for receipt ID so all receipts are unique regardless of what order sub-system they come from. So we have a problem where sometimes sequence is known, sometimes it is not known but as you point out is still expected to be there, and sometimes combination of both. I will have to think about how to merge your solution with @xorock #162, including tests that this PR does not have. Unless you will beat me to it and have better solution, I may consider making a separate PR that puts the two of these together. |
When sequence located in outer schema or sequenceName contain quote symbols, method nextSequenceId can't fetch next id, throw exception. For example:
This solution allow fix it