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
drop_constraint() does not quote check constraint name #487
Comments
Changes by Robert Buchholz (@rbuchholz):
|
Robert Buchholz (@rbuchholz) wrote: FYI: This does not happen on type='foreignkey', type='unique' or op.drop_index. |
Changes by Robert Buchholz (@rbuchholz):
|
Michael Bayer (@zzzeek) wrote: Dots are controversial here, so here is a better test to illustrate that the basic quoting isn't present:
|
Michael Bayer (@zzzeek) wrote: |
Robert Buchholz (@rbuchholz) wrote: Thank you for the quick fix, as always. Why would you consider dots controversial -- is it because they have a meaning when not escaped? |
Michael Bayer (@zzzeek) wrote: dots are often trying to actually produce a "schemaname.tablename" combination or otherwise work within some namespacing provided by the database. the dot is an operator so it's not always clear it's meant as an arbitrary character and not an operator. for a constraint name, it would be very unusual for the dot to be used this way but you never know what some new database does. |
Changes by Michael Bayer (@zzzeek):
|
Robert Buchholz (@rbuchholz) wrote: I actually experimented with a new naming convention where constraint name parts are separated by dots, which is how I stumbled upon this issue. |
Michael Bayer (@zzzeek) wrote: I would stick with underscores and not overthink it, it's always nice to not venture into quoting territory and there's not really any other non-alphanumeric characters that won't trigger quoting. looks like the dollar sign isn't quoted either, if you want to try that. the reg is: r'^[A-Z0-9_$]+$'. |
Michael Bayer (@zzzeek) wrote: I haven't released yet so please work around this by using quoted_name: |
Michael Bayer (@zzzeek) wrote: hmmmm, though that might not even work. |
Robert Buchholz (@rbuchholz) wrote: I tend to agree with the caution regarding the use of dots in identifiers, thank you for the insight. Maybe $ is a better option, on the other hand it moves the strict quoting requirement from SQL to Shell scripts operating on databases. I've tried
|
Change-Id: Ib85de299c5f3c2631c64fe30006879ba274fca15 Fixes: sqlalchemy#487
Change-Id: Ib85de299c5f3c2631c64fe30006879ba274fca15 Fixes: sqlalchemy#487
Migrated issue, originally created by Robert Buchholz (@rbuchholz)
Alembic does not quote a constraint name (at least for MariaDB). If it contains a dot, (in the best case) MariaDB will complain (depending on the number of dots) about missing tables or databases. In the worst case, a constraint on a schema and table not referenced by the table and schema arguments might be dropped.
Actual behavior:
Versions:
The text was updated successfully, but these errors were encountered: