Skip to content

fix: fix test after a patch bb0dd494862c ("sql: fix work of bind variables") - #105

Merged
rybakit merged 1 commit into
tarantool-php:masterfrom
NinaRodicova:ninarodicova/fix_test
Nov 6, 2026
Merged

rybakit merged 1 commit into
tarantool-php:masterfrom
NinaRodicova:ninarodicova/fix_test

Conversation

@NinaRodicova

Copy link
Copy Markdown
Contributor

No description provided.

@NinaRodicova
NinaRodicova force-pushed the ninarodicova/fix_test branch from 1700345 to dfd29d8 Compare October 29, 2026 20:14
$stmt = $this->client->prepare('INSERT INTO prepare_execute VALUES(:id, :name)');

$insertResult1 = $stmt->executeUpdate(1, 'foo');
$insertResult2 = $stmt->executeUpdate([':id' => 1], [':name' => 'foo']);

@rybakit rybakit Oct 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that, previously, it was possible to pass positional parameters to a query with named placeholders like

INSERT INTO foo VALUES(:id, :name)

as long as their order matched the placeholders, but with this change, that no longer works?

The test now fails because id is bound to NULL:

Failed to execute SQL statement: NOT NULL constraint failed: prepare_execute.id

But what happens if someone tries to update a nullable column and passes its value positionally instead of by name? For example:

UPDATE invoices SET discount_amount = :discount_amount WHERE id IN (
    SELECT id FROM invoices WHERE discount_amount IS NOT NULL
)

If the client passes the value positionally rather than by the name discount_amount, will existing discount amounts be silently set to NULL? Based on the error above, it looks like it. If so, is this intended behavior, or is it a regression?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will be set to NULL.
According to the new rules, queries with named variables require an array containing those named variables (for example, if a query uses :id, you must provide an array like {{[":id"] = 1}}). The positional approach is supported only for anonymous variables (?) and positional variables (e.g., $1); for instance, using ? or $1 in a query will work with an array like {1}.
The change was not unintentional.

@NinaRodicova
NinaRodicova force-pushed the ninarodicova/fix_test branch from 026db10 to 376b9e5 Compare November 2, 2026 07:17
@NinaRodicova
NinaRodicova requested a review from rybakit November 2, 2026 07:19
@NinaRodicova
NinaRodicova force-pushed the ninarodicova/fix_test branch 2 times, most recently from e202858 to 118cbfe Compare November 3, 2026 06:36
@NinaRodicova
NinaRodicova force-pushed the ninarodicova/fix_test branch from 118cbfe to fc19c7d Compare November 6, 2026 14:44
@rybakit
rybakit merged commit 82e9ff4 into tarantool-php:master Nov 6, 2026
28 checks passed
@rybakit

rybakit commented Nov 6, 2026

Copy link
Copy Markdown
Member

Note: This PR intentionally contains only the minimal changes needed for compatibility with #13565. Tests for the proposed behavior described in RFC #13620 will be added separately, once the RFC is agreed upon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants