Skip to content

Commit

Permalink
Update SQL.js to fix head operations for pg engine.
Browse files Browse the repository at this point in the history
Postgres requires the "length" function vs "len" function as some SQL engines us, this patch would add the correct wrapping in the getBlobSizefn
  • Loading branch information
rrindels authored Apr 30, 2024
1 parent 3580d1f commit 3cf452e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion engines/SQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,22 @@ module.exports = class SQLEngine extends Component {
// some column name aliases to adjust to default DB case
let CREATED = 'created'
let UPDATED = 'updated'


/*Postgres requires "length" instead of len for bytea fields. Noticed failures during head operations.
The other option would be to create a postgres function called len() on setup create which wraps the length() operation.
CREATE OR REPLACE FUNCTION len(byteafield bytea)
RETURNS int AS
$$
BEGIN
RETURN length(byteafield);
END;
$$
LANGUAGE plpgsql IMMUTABLE;
*/
if (this.client === 'pg'){
this.getBlobSizefn = "length(\"V\")"
}

if (this.client === 'mssql') {
this.getBlobSizeFn = 'len(V)'
this.mergeStmt = `
Expand Down

0 comments on commit 3cf452e

Please sign in to comment.