@ronin/compiler
Advanced tools
Comparing version 0.1.0 to 0.1.1-leo-ron-1083-experimental.0
@@ -381,16 +381,24 @@ // src/utils/index.ts | ||
// src/instructions/with.ts | ||
var WITH_CONDITIONS = [ | ||
"being", | ||
"notBeing", | ||
"startingWith", | ||
"notStartingWith", | ||
"endingWith", | ||
"notEndingWith", | ||
"containing", | ||
"notContaining", | ||
"greaterThan", | ||
"greaterOrEqual", | ||
"lessThan", | ||
"lessOrEqual" | ||
]; | ||
var getMatcher = (value, negative) => { | ||
if (negative) { | ||
if (value === null) return "IS NOT"; | ||
return "!="; | ||
} | ||
if (value === null) return "IS"; | ||
return "="; | ||
}; | ||
var WITH_CONDITIONS = { | ||
being: (value, baseValue) => `${getMatcher(baseValue, false)} ${value}`, | ||
notBeing: (value, baseValue) => `${getMatcher(baseValue, true)} ${value}`, | ||
startingWith: (value) => `LIKE ${value}%`, | ||
notStartingWith: (value) => `NOT LIKE ${value}%`, | ||
endingWith: (value) => `LIKE %${value}`, | ||
notEndingWith: (value) => `NOT LIKE %${value}`, | ||
containing: (value) => `LIKE %${value}%`, | ||
notContaining: (value) => `NOT LIKE %${value}%`, | ||
greaterThan: (value) => `> ${value}`, | ||
greaterOrEqual: (value) => `>= ${value}`, | ||
lessThan: (value) => `< ${value}`, | ||
lessOrEqual: (value) => `<= ${value}` | ||
}; | ||
var handleWith = (schemas, schema, statementValues, instruction, rootTable) => { | ||
@@ -451,23 +459,7 @@ const subStatement = composeConditions( | ||
if (options.type === "values") return conditionValue; | ||
const conditionTypes = { | ||
being: [getMatcher(value, false), conditionValue], | ||
notBeing: [getMatcher(value, true), conditionValue], | ||
startingWith: ["LIKE", `${conditionValue}%`], | ||
notStartingWith: ["NOT LIKE", `${conditionValue}%`], | ||
endingWith: ["LIKE", `%${conditionValue}`], | ||
notEndingWith: ["NOT LIKE", `%${conditionValue}`], | ||
containing: ["LIKE", `%${conditionValue}%`], | ||
notContaining: ["NOT LIKE", `%${conditionValue}%`], | ||
greaterThan: [">", conditionValue], | ||
greaterOrEqual: [">=", conditionValue], | ||
lessThan: ["<", conditionValue], | ||
lessOrEqual: ["<=", conditionValue] | ||
}; | ||
return `${conditionSelector} ${conditionTypes[options.condition || "being"].join(" ")}`; | ||
return `${conditionSelector} ${WITH_CONDITIONS[options.condition || "being"](conditionValue, value)}`; | ||
}; | ||
var composeConditions = (schemas, schema, statementValues, instructionName, value, options) => { | ||
const isNested = isObject(value) && Object.keys(value).length > 0; | ||
if (isNested && Object.keys(value).every( | ||
(key) => WITH_CONDITIONS.includes(key) | ||
)) { | ||
if (isNested && Object.keys(value).every((key) => key in WITH_CONDITIONS)) { | ||
const conditions = Object.entries(value).map( | ||
@@ -562,10 +554,2 @@ ([conditionType, checkValue]) => composeConditions(schemas, schema, statementValues, instructionName, checkValue, { | ||
}; | ||
var getMatcher = (value, negative) => { | ||
if (negative) { | ||
if (value === null) return "IS NOT"; | ||
return "!="; | ||
} | ||
if (value === null) return "IS"; | ||
return "="; | ||
}; | ||
var formatIdentifiers = ({ identifiers }, queryInstructions) => { | ||
@@ -572,0 +556,0 @@ if (!queryInstructions) return queryInstructions; |
{ | ||
"name": "@ronin/compiler", | ||
"version": "0.1.0", | ||
"version": "0.1.1-leo-ron-1083-experimental.0", | ||
"type": "module", | ||
@@ -11,3 +11,5 @@ "description": "Compiles RONIN queries to SQL statements.", | ||
"types": "./dist/index.d.ts", | ||
"files": ["dist"], | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
@@ -22,3 +24,7 @@ "lint": "bun run --bun lint:tsc && bun run --bun lint:biome", | ||
}, | ||
"keywords": ["query", "compiler", "sql"], | ||
"keywords": [ | ||
"query", | ||
"compiler", | ||
"sql" | ||
], | ||
"author": "ronin", | ||
@@ -25,0 +31,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
0
345975
5772
1