-
Notifications
You must be signed in to change notification settings - Fork 435
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
SQLServerException: Cannot insert the value NULL into column 'name'" when calling DatabaseMetaData.getImportedKeys #681
Comments
The problem appears to happen when getImportedKeys is called for a table with foreign keys in a database different from that specified in the original connection JDBC URL. In the above case, in SQLServerDatabaseMetaData.getResultSetForForeignKeyInformation, sys.foreign_keys returns zero rows (because it only includes tables in the current database?) while the fkeys_results table has at least one row (one for each foreign key). The outer RIGHT JOIN between the two tables then causes nulls to appear in the name, delete_referential_action_desc, and update_referential_action_desc columns. When these null values are inserted into foreign_keys_combined_results, the error occurs. |
Hi @eirikbakke, I was able to to reproduce the issue you described with the 6.4.0 driver, but it seems the changes addressing #665 does not have this issue. Do you mind testing with the new changes and see if it resolves the problems. |
Yes, I can confirm the JAR you sent works. Thanks for your attention! |
#677 has now been merged. Closing the issue. |
Driver version or jar name
6.4.0 (bisection reveals bug introduced in 6.3.3)
SQL Server version
Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64)
Developer Edition (64-bit) on Windows 10 Enterprise 6.3 (Build 15063: ) (Hypervisor)
Client operating system
Windows 10
Java/JVM version
1.8.0_112
Table schema
WideWorldImporters/Application/Cities in the WideWorldImporters example shipped with SQL Server.
Problem description
"SQLServerException: Cannot insert the value NULL into column 'name'" when calling DatabaseMetaData.getImportedKeys("WideWorldImporters", "Application", "Cities")
Expected behavior and actual behavior
The call to getImportedKeys should not throw an exception.
Repro code
The text was updated successfully, but these errors were encountered: