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
SchemaDumper table_name_prefix and table_name_suffix with dollar sign support #30044
Comments
Created a dirty workaround fix yahonda@2d674ac |
It is better to use prefix = Regexp.escape(@options[:table_name_prefix])
suffix = Regexp.escape(@options[:table_name_suffix])
table.sub(/\A(?:#{prefix})(.+)(?:#{suffix})\z/, "\\1") |
Thanks as always. |
Opened #30048. Added
|
yahonda
added a commit
to yahonda/rails
that referenced
this issue
Aug 4, 2017
MySQL 5.7 and PostgreSQL 9.6 allow table identifiers have the dollar sign. * MySQL 5.7 https://dev.mysql.com/doc/refman/5.7/en/identifiers.html > Permitted characters in unquoted identifiers: > ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore) * PostgreSQL 9.6 https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html > SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard. Address rails#30044 [Yasuo Honda & Ryuta Kamizono]
yahonda
added a commit
to yahonda/oracle-enhanced
that referenced
this issue
Aug 16, 2017
Since rails/rails#30048 there is no Oracle enhanced specific implementation anymore. Tests are covered by `ActiveRecord::TestCase::SchemaDumperTest` Refer rsim#1401 rails/rails#30044 rails/rails#30048
yahonda
added a commit
to yahonda/oracle-enhanced
that referenced
this issue
Aug 16, 2017
Since rails/rails#30048 there is no Oracle enhanced specific implementation anymore. Tests are covered by `ActiveRecord::TestCase::SchemaDumperTest` Refer rsim#1401 rails/rails#30044 rails/rails#30048
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
When
table_name_prefix
andtable_name_suffix
have the dollar sign "$",SchemaDumper
generates table name withtable_name_prefix
andtable_name_suffix
.It should remove
table_name_prefix
andtable_name_suffix
.Steps to reproduce
$ git clone http://github.com/yahonda/rep_schema_dumper_prefix_suffix_dollar_sign
$ cd rep_schema_dumper_prefix_suffix_dollar_sign
$ ruby rep_sqlite3.rb
Expected behavior
It should generate table name without
table_name_prefix
andtable_name suffix
. Just "posts".Actual behavior
It generates "foo$posts$bar". with when
table_name_prefix = "foo$"
andActiveRecord::Base.table_name_suffix = "$bar"
\n
with actual new line:System configuration
Rails version: master branch
Ruby version: 2.4.1
Additional information
I have found this behavior when I'm working for refactoring Oracle enhanced adapter
to use
SchemaDumper#remove_prefix_and_suffix
rsim/oracle-enhanced#1401Oracle enhanced adapter allows (I mean it has test cases)
table_name_prefix
andtable_name_suffix
have the dollar sign.From database point of view MySQL 5.7, PostgreSQL 9.6 and Oracle Database 12.1 allows table identifiers have dollar sign.
https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
https://www.postgresql.org/docs/9.6/static/sql-syntax-lexical.html
https://docs.oracle.com/database/121/SQLRF/sql_elements008.htm#SQLRF51129
Have not found if SQLite3 allows it or not.
The text was updated successfully, but these errors were encountered: