Skip to content

Commit

Permalink
chore: prettier and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza committed Oct 30, 2023
1 parent 2f2076f commit b58699e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
33 changes: 15 additions & 18 deletions integration/testdata/with_custom_function_hooks/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ describe("write hooks", () => {
actions.withIdentity(identity).createPersonWithAfterWrite({
title: "Bob",
sex: Sex.Male,
})
}),
).toHaveAuthorizationError();

await expect(
actions.withIdentity(identity).createPersonWithBeforeWrite({
title: "Alice",
sex: Sex.Female,
})
}),
).not.toHaveAuthorizationError();
});

Expand Down Expand Up @@ -83,12 +83,11 @@ describe("write hooks", () => {
title: "Adam",
sex: Sex.Male,
},
})
}),
).toHaveAuthorizationError();
});


test("update action - updatedAt set", async () => {
test("update.beforeWrite hook - updatedAt set", async () => {
const identity = await models.identity.create({
email: "[email protected]",
});
Expand All @@ -104,7 +103,7 @@ describe("write hooks", () => {

await delay(100);

const record = await actions
const record = await actions
.withIdentity(identity)
.updatePersonWithBeforeWrite({
where: { id: person.id },
Expand All @@ -113,19 +112,17 @@ describe("write hooks", () => {
sex: Sex.Female,
},
});
console.log(person);
console.log(record);

const person2 = await models.person.findOne({id: person.id});
console.log(person2);


expect(record.updatedAt.valueOf()).toBeGreaterThanOrEqual(person.createdAt.valueOf() + 100);
expect(record.updatedAt.valueOf()).toBeLessThan(person.createdAt.valueOf() + 1000);
expect(record.updatedAt.valueOf()).toBeGreaterThanOrEqual(
person.createdAt.valueOf() + 100,
);
expect(record.updatedAt.valueOf()).toBeLessThan(
person.createdAt.valueOf() + 1000,
);
});

function delay(ms: number) {
return new Promise( resolve => setTimeout(resolve, ms) );
return new Promise((resolve) => setTimeout(resolve, ms));
}
});

Expand All @@ -140,7 +137,7 @@ describe("query hooks", () => {
});

await expect(
actions.withIdentity(identity).deletePersonBeforeQuery({ id: person.id })
actions.withIdentity(identity).deletePersonBeforeQuery({ id: person.id }),
).toHaveError({
message: "record not found",
});
Expand Down Expand Up @@ -188,7 +185,7 @@ describe("query hooks", () => {
await expect(
actions.withIdentity(identity).getPersonBeforeQuery({
id: person.id,
})
}),
).toHaveError({
message: "no result",
});
Expand Down Expand Up @@ -274,7 +271,7 @@ describe("query hooks", () => {
sex: Sex.Male,
title: person.title,
},
})
}),
).rejects.toThrowError("record not found");
});

Expand Down
2 changes: 1 addition & 1 deletion migrations/testdata/default_value_initial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ model Person {
===

CREATE TABLE "identity" (
"email" TEXT,pauthen
"email" TEXT,
"email_verified" BOOL NOT NULL DEFAULT false,
"password" TEXT,
"external_id" TEXT,
Expand Down
12 changes: 6 additions & 6 deletions packages/testing-runtime/src/Executor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Executor {
method: "POST",
body: JSON.stringify(params),
headers,
}).then(async (r) => {
}).then((r) => {
if (r.status !== 200) {
// For non-200 first read the response as text
return r.text().then((t) => {
Expand All @@ -101,11 +101,11 @@ export class Executor {
});
}

return r.text().then((t) => {
if (this._parseJsonResult) {
if (this._parseJsonResult) {
return r.text().then((t) => {
return JSON.parse(t, reviver);
}
});
});
}
});
}
}
Expand All @@ -117,4 +117,4 @@ function reviver(key, value) {
return new Date(value);
}
return value;
}
}
4 changes: 0 additions & 4 deletions runtime/actions/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"sort"
"strings"
"time"

"github.com/samber/lo"
"github.com/teamkeel/keel/casing"
Expand Down Expand Up @@ -812,9 +811,6 @@ func orderGraphNodes(graph *Row) []*Row {

// Generates an executable UPDATE statement with the list of arguments.
func (query *QueryBuilder) UpdateStatement() *Statement {
// Implicitly update the updatedAt column for any update to the model
query.AddWriteValue(Field(parser.ImplicitFieldNameUpdatedAt), Value(time.Now().UTC()))

queryFilters := query.filters

joins := ""
Expand Down

0 comments on commit b58699e

Please sign in to comment.