sqlacodegen
sqlacodegen copied to clipboard
Allow for variable whitespace in “CHECK” enum constraints
allow for multiple spaces before the check keyword and any amount of white space (including 0) after the check keyword but before the in keyword:
For example, if your constraints was CHECK IN('a', 'b', 'c')
, this would not be recognized.
coverage: 97.639%. remained the same when pulling c07f3a076b31906237af0a681096f0ad1aff5bc6 on Dsolnik:patch-1 into c68d2a8a0ec3511afb96983bdce6e2498aaa72b3 on agronholm:master.
I don't think the changes you made do what you think they do.
Basically all your changes do is allow any amount of whitespace before and after the IN
.
Tired Thursday apologies.
Yes, this PR allows for multiple spaces before the check keyword and any amount of white space (including 0) after the check keyword but before the in keyword.
Just what kind of CHECK constraint did you have a problem with that wouldn't work with the existing code? I have a hard time understanding.
My constraint was “CHECK IN('a', 'b', 'c')”, notice the lack of spaces after the IN
I thought the RDBMS would normalize these. What RDBMS was this on?
Admittedly, this was an oversight when I uploaded the schema but it was recognized as valid sql (and worked as a constraint) in SQLite and SQL Server.
On Thu, Sep 28, 2023 at 7:05 PM Alex Grönholm @.***> wrote:
Just what kind of CHECK constraint did you have a problem with that wouldn't work with the existing code? I have a hard time understanding.
— Reply to this email directly, view it on GitHub https://github.com/agronholm/sqlacodegen/pull/289#issuecomment-1740106817, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD64FZXYZTSDAKUSVINLJ5TX4X7DRANCNFSM6AAAAAA5LUC6DY . You are receiving this because you authored the thread.Message ID: @.***>
Ah, that answers my question. I guess it's only PostgreSQL that normalizes those then.
I will need an accompanying test to ensure that the PR fixes what it says it fixes (and won't break in the future). Meanwhile I'll experiment with sqlite (I don't know how to operate SQL Server).
Yea, not only that but SQLite returns back the comment associated with the constraint (rip).
I didn’t check if this was the case for sql server.
On Thu, Sep 28, 2023 at 7:14 PM Alex Grönholm @.***> wrote:
Ah, that answers my question. I guess it's only PostgreSQL that normalizes those then.
— Reply to this email directly, view it on GitHub https://github.com/agronholm/sqlacodegen/pull/289#issuecomment-1740112707, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD64FZRLMFKW6LU5BDXQLZ3X4YAGFANCNFSM6AAAAAA5LUC6DY . You are receiving this because you authored the thread.Message ID: @.***>
@Dsolnik would you also be able to add a fix for https://github.com/agronholm/sqlacodegen/issues/291? In this instance the spaces were are the start and end of the constraint eg " CAP_RESTRICT_LEVEL IN ('NONE', 'WARN', 'RESTRICT') "
. I was in the process of creating a pr but looks like you are already making changes ;)