Skip to content

Commit

Permalink
db/unjoiner: remove extra sql`` wrapper (#1374)
Browse files Browse the repository at this point in the history
Introduced in #1240, but not resolved before merge.
  • Loading branch information
alxndrsn authored Jan 22, 2025
1 parent 1dd47fe commit bb7dc03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/util/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const unjoiner = (...frames) => {
return new frames[0](primary, bag);
};

unjoin.fields = sql`${sql.join(fields, sql`,`)}`; // FIXME remove wrapping sql``
unjoin.fields = sql.join(fields, sql`,`);
return unjoin;
};

Expand Down
9 changes: 4 additions & 5 deletions test/unit/util/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ describe('util/db', () => {
const T = Frame.define(table('frames'), 'x', 'y');
const U = Frame.define(into('extra'), 'z');
it('should generate fields', () => {
unjoiner(T, U)
.fields.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","z" as "z"`);
sql`${unjoiner(T, U).fields}`.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","z" as "z"`);
});

it('should unjoin data', () => {
Expand All @@ -219,7 +218,7 @@ describe('util/db', () => {

it('should optionally unjoin optional data', () => {
const unjoin = unjoiner(T, Option.of(U));
unjoin.fields.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","z" as "z"`);
sql`${unjoin.fields}`.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","z" as "z"`);
unjoin({ 'frames!x': 3, 'frames!y': 4, z: 5 })
.should.eql(new T({ x: 3, y: 4 }, { extra: Option.of(new U({ z: 5 })) }));
unjoin({ 'frames!x': 3, 'frames!y': 4 })
Expand All @@ -239,7 +238,7 @@ describe('util/db', () => {
it('should provide the appropriate arguments when not extended', () => {
let run = false;
extender(T)(U)((fields, extend, options, x, y, z) => {
fields.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y"`);
sql`${fields}`.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y"`);
(sql`${extend|| true}`).should.eql(sql``);
x.should.equal(2);
y.should.equal(3);
Expand All @@ -252,7 +251,7 @@ describe('util/db', () => {
it('should provide the appropriate arguments when extended', () => {
let run = false;
extender(T)(U)((fields, extend, options, x, y, z) => {
fields.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","a" as "a","b" as "b"`);
sql`${fields}`.should.eql(sql`"frames"."x" as "frames!x","frames"."y" as "frames!y","a" as "a","b" as "b"`);
(sql`${extend|| true}`).should.eql(sql`${true}`);
x.should.equal(2);
y.should.equal(3);
Expand Down

0 comments on commit bb7dc03

Please sign in to comment.