Skip to content

Commit 60da349

Browse files
committed
Pull request that added support for CASE WHEN broke Postgres.visitColumn when column implicitly aliased is used in CASE. Pull request to better support js property to column-name mapping broke AS aliasing during Postgres.visitReturning.
This change fixes both issues.
1 parent 63cd294 commit 60da349

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

test/column-tests.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ describe('column', function() {
114114
it('but not when with explicit property name', function() {
115115
assert.equal(table.not2Cam.toQuery().text, '"sc"."not_to_camel" AS "not2Cam"');
116116
});
117-
})
117+
it('does not use property alias within CASE ... END', function() {
118+
assert.equal(table.makeMeCamel.case([table.makeMeCamel.equals(0)],[table.makeMeCamel]).as('rename').toQuery().text,
119+
'(CASE WHEN ("sc"."make_me_camel" = $1) THEN "sc"."make_me_camel" END) AS "rename"');
120+
});
121+
it('respects AS rename in RETURNING clause', function() {
122+
assert.equal(table.update({makeMeCamel:0}).returning(table.makeMeCamel.as('rename')).toQuery().text,
123+
'UPDATE "sc" SET "make_me_camel" = $1 RETURNING "sc"."make_me_camel" AS "rename"');
124+
});
125+
});
118126
});
119127
});

0 commit comments

Comments
 (0)