Pg: Add escape_literal() and escape_identifier()
Didn't expect I'd ever need these, but they're useful for generating SQL scripts.
This commit is contained in:
parent
3bf98e4d8f
commit
b3281924d1
4 changed files with 41 additions and 0 deletions
|
|
@ -353,6 +353,16 @@ subtest 'txn', sub {
|
|||
is_deeply $st->val, [1,3], 'not deep copy';
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
# Exact format returned by escape_literal() can differ between Postgres versions and configurations.
|
||||
my $x = q{"' \" \\};
|
||||
is $conn->q('SELECT '.$conn->escape_literal($x))->val, $x;
|
||||
|
||||
# Format can also change, but unsure how to test this otherwise.
|
||||
is $conn->escape_identifier('hel\l"o'), '"hel\l""o"';
|
||||
}
|
||||
|
||||
subtest 'Prepared statement cache', sub {
|
||||
my $txn = $conn->cache_size(2)->txn->cache;
|
||||
my sub numexec($sql) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue