Skip to content

Change identity columns to use direct SQL query when cross database #1356

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

Open
wants to merge 2 commits into
base: 7-2-stable
Choose a base branch
from

Conversation

chrisortman
Copy link

This is related to #1355

When trying to get identity columns, schema_cache is only valid if the database you are inserting into is the database you are connected to.

This change checks the table to see if it is database qualified and if so does a direct query to get identity columns using the system schema of the target database.

When target database is current database I preserved the old behavior so that it does not suddenly introduce an extra query for every insert. This also keeps the active record tests happy.

I did the fix against 7.2 stable because that is what I am currently running my my prod apps. If we can figure out if this is the correct approach I can port it to 8 and main as well.

@aidanharan
Copy link
Contributor

aidanharan commented Aug 8, 2025

@chrisortman The test cases are too low level. They don't show the inserting issue you are having or whether the issue has been fixed by your changes. Could you review #1357 and let me know if that recreates the exact error you are encountering?

@chrisortman
Copy link
Author

@aidanharan Yes that reproduces the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants