-
-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Description
- bug report? yes
- feature request? nono
- version: 2.4.3
Description
Get error syntax exception, when mixing short (with suffix ) and long string parameters binding to INSERT or UPDATE query (maybe there are probably more scenarios to get this error).
Steps To Reproduce
I have tested this with PostqreSQL. Let's create this simple table:
CREATE TABLE test
(
col1 text,
col2 text,
col3 text
);Then run this command:
/** @var \Nette\Database\Context $context */
$context->table('test')->insert([
'col1' => 'some text \\', // shorter than 20
'col2' => 'some text longer than 20 characters',
'col3' => 'some text', // shorter than 20
]);This exception is thrown:
Nette\Database\DriverException #42601
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ","
LINE 1: ... ("col1", "col2", "col3") VALUES ('some text \', ?, 'some te...
This behavior is probably fixed in 3.0.0-alpha with commit 644b587. To fix this in 2.4 branch it is possible to change SqlPreprocessor->formatValue to bind all strings as variable, not only strings longer than 20 characters. Bud I don't why this logic is there, maybe this update could be BC?
Metadata
Metadata
Assignees
Labels
No labels