-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`NOT` is implemented using De Morgan's law so it is not represented in the AST. This adds a few more SimpleOperators to deal with things like `NOT` `IN` etc.
- Loading branch information
Showing
7 changed files
with
295 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {EntitySchema} from '../schema/entity-schema.js'; | ||
import {WhereCondition} from './entity-query.js'; | ||
|
||
export function conditionToString<S extends EntitySchema>( | ||
c: WhereCondition<S>, | ||
paren = false, | ||
): string { | ||
if (c.op === 'AND' || c.op === 'OR') { | ||
let s = ''; | ||
if (paren) { | ||
s += '('; | ||
} | ||
{ | ||
const paren = c.op === 'AND' && c.conditions.length > 1; | ||
s += c.conditions.map(c => conditionToString(c, paren)).join(` ${c.op} `); | ||
} | ||
if (paren) { | ||
s += ')'; | ||
} | ||
return s; | ||
} | ||
return `${(c as {field: string}).field} ${c.op} ${(c as {value: {value: unknown}}).value.value}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.