You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Knex version: 3.1.0
Database + version: Oracle 19c
OS: Windows 11 and Linux (Ubuntu and Alpine Distros)
Bug
Explain what kind of behavior you are getting and what you think it should do
Knex encounters issues in Oracle database when certain migration commands, particularly rename and drop commands, are executed when a custom wrapIdentifier option is specified in the knexfile - particularly when this option is used to normalize casing and formatting of database objects (ex. camelCase to UPPER_SNAKE_CASE)
Error message
Error indicating that the table/trigger/sequence/etc. to drop or rename does not exist, even when the exact same string used to create the database object is provided as the target for a delete or rename operation.
Reduced test code
constknex=require('knex')const{ snakecase, uppercase }=require('stringcase')constdb=knex({client: 'oracledb',connection: {host: '<DB HOSTNAME>',database: '<DATABASE>',user: '<USER>',password: '<PASSWORD>',},wrapIdentifier: (value,origImpl,queryContext)=>origImpl(uppercase(snakecase(value))),})awaitdb.scema.createTable('exampleTable',(table)=>{// Resultant table name is "EXAMPLE_TABLE" and is created sucessfully// auto-generated sequence for this table is named "example_table_seq"// table builder statements});awaitdb.schema.renameTable('exampleTable','newTable');// Fails with error from Oracle stating that table "exampleTable" does not exist - Name was not formattedawaitdb.schema.dropTableIfExists('exampleTable');// drops "EXAMPLE_TABLE", attempts to drop "EXAMPLE_TABLE_SEQ"// Oracle throws an error because "EXAMPLE_TABLE_SEQ" does not exist
Proposed Fix and Further Explanation
I have opened a PR with a fix to the issue, #6058 though this PR has not yet been reviewed by the maintainers.
Knex quotes database object names in the queries passed to oracle, which results in these objects preserving the case in their names, where tables would otherwise be treated in a case-insensitive way if unquoted, which explains the issue with example_table_seq illustrated above, even though all the underscore characters line up.
For a more in-depth explanation of the cause of the issue, please see the referenced PR, which also details my proposed fix to the issue.
Environment
Knex version: 3.1.0
Database + version: Oracle 19c
OS: Windows 11 and Linux (Ubuntu and Alpine Distros)
Bug
Knex encounters issues in Oracle database when certain migration commands, particularly rename and drop commands, are executed when a custom wrapIdentifier option is specified in the knexfile - particularly when this option is used to normalize casing and formatting of database objects (ex. camelCase to UPPER_SNAKE_CASE)
Error indicating that the table/trigger/sequence/etc. to drop or rename does not exist, even when the exact same string used to create the database object is provided as the target for a delete or rename operation.
Proposed Fix and Further Explanation
I have opened a PR with a fix to the issue, #6058 though this PR has not yet been reviewed by the maintainers.
Knex quotes database object names in the queries passed to oracle, which results in these objects preserving the case in their names, where tables would otherwise be treated in a case-insensitive way if unquoted, which explains the issue with example_table_seq illustrated above, even though all the underscore characters line up.
For a more in-depth explanation of the cause of the issue, please see the referenced PR, which also details my proposed fix to the issue.
@atiertant
The text was updated successfully, but these errors were encountered: