-
-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33f4f10
commit 2881b4c
Showing
37 changed files
with
736 additions
and
730 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
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 @@ | ||
export const MySqlViewConfig = Symbol.for('drizzle:MySqlViewConfig'); |
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
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,95 @@ | ||
function parsePgArrayValue(arrayString: string, startFrom: number, inQuotes: boolean): [string, number] { | ||
for (let i = startFrom; i < arrayString.length; i++) { | ||
const char = arrayString[i]; | ||
|
||
if (char === '\\') { | ||
i++; | ||
continue; | ||
} | ||
|
||
if (char === '"') { | ||
return [arrayString.slice(startFrom, i).replace(/\\/g, ''), i + 1]; | ||
} | ||
|
||
if (inQuotes) { | ||
continue; | ||
} | ||
|
||
if (char === ',' || char === '}') { | ||
return [arrayString.slice(startFrom, i).replace(/\\/g, ''), i]; | ||
} | ||
} | ||
|
||
return [arrayString.slice(startFrom).replace(/\\/g, ''), arrayString.length]; | ||
} | ||
|
||
export function parsePgNestedArray(arrayString: string, startFrom = 0): [any[], number] { | ||
const result: any[] = []; | ||
let i = startFrom; | ||
let lastCharIsComma = false; | ||
|
||
while (i < arrayString.length) { | ||
const char = arrayString[i]; | ||
|
||
if (char === ',') { | ||
if (lastCharIsComma || i === startFrom) { | ||
result.push(''); | ||
} | ||
lastCharIsComma = true; | ||
i++; | ||
continue; | ||
} | ||
|
||
lastCharIsComma = false; | ||
|
||
if (char === '\\') { | ||
i += 2; | ||
continue; | ||
} | ||
|
||
if (char === '"') { | ||
const [value, startFrom] = parsePgArrayValue(arrayString, i + 1, true); | ||
result.push(value); | ||
i = startFrom; | ||
continue; | ||
} | ||
|
||
if (char === '}') { | ||
return [result, i + 1]; | ||
} | ||
|
||
if (char === '{') { | ||
const [value, startFrom] = parsePgNestedArray(arrayString, i + 1); | ||
result.push(value); | ||
i = startFrom; | ||
continue; | ||
} | ||
|
||
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false); | ||
result.push(value); | ||
i = newStartFrom; | ||
} | ||
|
||
return [result, i]; | ||
} | ||
|
||
export function parsePgArray(arrayString: string): any[] { | ||
const [result] = parsePgNestedArray(arrayString, 1); | ||
return result; | ||
} | ||
|
||
export function makePgArray(array: any[]): string { | ||
return `{${ | ||
array.map((item) => { | ||
if (Array.isArray(item)) { | ||
return makePgArray(item); | ||
} | ||
if (typeof item === 'string' && item.includes(',')) { | ||
return `"${item.replace(/"/g, '\\"')}"`; | ||
} | ||
return `${item}`; | ||
}).join(',') | ||
}}`; | ||
} |
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 @@ | ||
export * from './array.ts'; |
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 @@ | ||
export const PgViewConfig = Symbol.for('drizzle:PgViewConfig'); |
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
Oops, something went wrong.