-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug: incomplete join in CodeIgniter\Database\MySQLi\Connection::_foreignKeyData() #4996
Comments
lukemim
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
Aug 11, 2021
MGatner
added
the
database
Issues or pull requests that affect the database layer
label
Aug 11, 2021
@lukemim Could you please follow the bug report template? |
I confirmed the bug. SELECT
tc.CONSTRAINT_NAME,
tc.TABLE_NAME,
kcu.COLUMN_NAME,
rc.REFERENCED_TABLE_NAME,
kcu.REFERENCED_COLUMN_NAME
FROM information_schema.TABLE_CONSTRAINTS AS tc
INNER JOIN information_schema.REFERENTIAL_CONSTRAINTS AS rc
ON tc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
INNER JOIN information_schema.KEY_COLUMN_USAGE AS kcu
ON tc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME
WHERE
tc.CONSTRAINT_TYPE = 'FOREIGN KEY' AND
tc.TABLE_SCHEMA = 'ci4_crud' AND
tc.TABLE_NAME = 'track';
|
SELECT
tc.CONSTRAINT_NAME,
tc.TABLE_NAME,
kcu.COLUMN_NAME,
rc.REFERENCED_TABLE_NAME,
kcu.REFERENCED_COLUMN_NAME
FROM information_schema.TABLE_CONSTRAINTS AS tc
INNER JOIN information_schema.REFERENTIAL_CONSTRAINTS AS rc
ON tc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
AND tc.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
INNER JOIN information_schema.KEY_COLUMN_USAGE AS kcu
ON tc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME
AND tc.CONSTRAINT_SCHEMA = kcu.CONSTRAINT_SCHEMA
WHERE
tc.CONSTRAINT_TYPE = 'FOREIGN KEY' AND
tc.TABLE_SCHEMA = 'ci4_crud' AND
tc.TABLE_NAME = 'track';
|
kenjis
added a commit
to kenjis/CodeIgniter4
that referenced
this issue
Nov 30, 2021
4 tasks
kenjis
added a commit
to kenjis/CodeIgniter4
that referenced
this issue
Dec 2, 2021
kenjis
added a commit
to kenjis/CodeIgniter4
that referenced
this issue
Dec 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the join in
CodeIgniter\Database\MySQLi\Connection::_foreignKeyData()
is joining overCONSTRAINT_NAME
only, but not overCONSTRAINT_SCHEMA
, so if there are multiple databases (schemas) containing constraints with the same names_foreignKeyData()
will return duplicated rows with metadata also from the other databases (schemas).I guess this is where the bug was created: 12ea7ba
CI 4.1.3
The text was updated successfully, but these errors were encountered: