Browse Source

Merge pull request #4766 from nocodb/fix/postgres-substr

fix(nocodb): SUBSTR for postgres
pull/4767/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
2ddee5b005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/pg.ts

10
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/pg.ts

@ -138,6 +138,16 @@ const pg = {
.toQuery()} THEN 1 ELSE 0 END ${args.colAlias}`
);
},
SUBSTR: ({ fn, knex, pt, colAlias }: MapFnArgs) => {
const str = fn(pt.arguments[0]);
const positionFrom = fn(pt.arguments[1] ?? 1);
const numberOfCharacters = fn(pt.arguments[2] ?? '');
return knex.raw(
`SUBSTR(${str}::TEXT, ${positionFrom}${
numberOfCharacters ? ', ' + numberOfCharacters : ''
})${colAlias}`
);
},
};
export default pg;

Loading…
Cancel
Save