[#1593] Factory.field("{1} + {0} + {0}", val(1), val(2)) doesn't work.

Cannot re-use / re-order placeholders - Improved SQLite function
simulations
This commit is contained in:
Lukas Eder 2012-10-21 18:28:07 +02:00
parent ee35c6481d
commit a44adbfdd1
3 changed files with 10 additions and 10 deletions

View File

@ -86,14 +86,14 @@ class Lpad extends AbstractFunction<String> {
"replace(" +
"substr(" +
"quote(" +
"zeroblob((({0} - length({1}) - 1 + length({2})) / length({3}) + 1) / 2)" +
"zeroblob((({1} - length({0}) - 1 + length({2})) / length({2}) + 1) / 2)" +
"), 3" +
"), '''', ''" +
"), '0', {4}" +
"), 1, ({5} - length({6}))" +
") || {7}",
"), '0', {2}" +
"), 1, ({1} - length({0}))" +
") || {0}",
String.class,
length, field, character, character, character, length, field, field);
field, length, character);
}
// According to the Firebird documentation, LPAD outcomes should be

View File

@ -73,7 +73,7 @@ class Repeat extends AbstractFunction<String> {
// Another option is documented here, though:
// http://stackoverflow.com/questions/11568496/how-to-simulate-repeat-in-sqlite
case SQLITE:
return Factory.field("replace(substr(quote(zeroblob(({0} + 1) / 2)), 3, {1}), '0', {2})", String.class, count, count, string);
return Factory.field("replace(substr(quote(zeroblob(({0} + 1) / 2)), 3, {0}), '0', {1})", String.class, count, string);
case ASE:
case SQLSERVER:

View File

@ -86,14 +86,14 @@ class Rpad extends AbstractFunction<String> {
"replace(" +
"substr(" +
"quote(" +
"zeroblob((({1} - length({2}) - 1 + length({3})) / length({4}) + 1) / 2)" +
"zeroblob((({1} - length({0}) - 1 + length({2})) / length({2}) + 1) / 2)" +
"), 3" +
"), '''', ''" +
"), '0', {5}" +
"), 1, ({6} - length({7}))" +
"), '0', {2}" +
"), 1, ({1} - length({0}))" +
")",
String.class,
field, length, field, character, character, character, length, field);
field, length, character);
}
// According to the Firebird documentation, LPAD outcomes should be