[#4515] Emulate POSITION() with INSTR() in SQLite
This commit is contained in:
parent
46a8a4ac6f
commit
ba8d7b72ca
@ -8688,7 +8688,7 @@ public class DSL {
|
||||
*
|
||||
* @see #position(Field, Field)
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<Integer> position(String in, String search) {
|
||||
return position(Utils.field(in, String.class), Utils.field(search, String.class));
|
||||
}
|
||||
@ -8698,7 +8698,7 @@ public class DSL {
|
||||
*
|
||||
* @see #position(Field, Field)
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<Integer> position(String in, Field<String> search) {
|
||||
return position(Utils.field(in, String.class), nullSafe(search));
|
||||
}
|
||||
@ -8708,7 +8708,7 @@ public class DSL {
|
||||
*
|
||||
* @see #position(Field, Field)
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<Integer> position(Field<String> in, String search) {
|
||||
return position(nullSafe(in), Utils.field(search, String.class));
|
||||
}
|
||||
@ -8723,7 +8723,7 @@ public class DSL {
|
||||
* instr([in], [search]) or
|
||||
* charindex([search], [in])</pre></code>
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static Field<Integer> position(Field<String> in, Field<String> search) {
|
||||
return new Position(nullSafe(search), nullSafe(in));
|
||||
}
|
||||
|
||||
@ -73,6 +73,10 @@ class Position extends AbstractFunction<Integer> {
|
||||
return field("{locate}({0}, {1})", SQLDataType.INTEGER, search, in);
|
||||
|
||||
/* [pro] xx
|
||||
xxxx xxxx
|
||||
xxxx xxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxx xxxx
|
||||
|
||||
xxxx xxxxx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxxxxx
|
||||
@ -80,13 +84,10 @@ class Position extends AbstractFunction<Integer> {
|
||||
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxx xxx xxxxxxxx
|
||||
|
||||
xxxx xxxx
|
||||
xxxx xxxxxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxx xxxx
|
||||
|
||||
xx [/pro] */
|
||||
case SQLITE:
|
||||
return field("{instr}({0}, {1})", SQLDataType.INTEGER, in, search);
|
||||
|
||||
default:
|
||||
return field("{position}({0} {in} {1})", SQLDataType.INTEGER, search, in);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user