-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(format): apply prettier changes post bestpracts upgrade
- Loading branch information
1 parent
be703c1
commit df2354a
Showing
158 changed files
with
2,175 additions
and
750 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
6 changes: 5 additions & 1 deletion
6
...ivelyHeavilyNormalizeViewDdl/normalizations/addSpacesBetweenCommaParenthesisOccurances.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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
/** | ||
* replace `,(` patterns w/ space in between, since our formatter downstream does not like that | ||
*/ | ||
export const addSpacesBetweenCommaParenthesisOccurances = ({ ddl }: { ddl: string }) => { | ||
export const addSpacesBetweenCommaParenthesisOccurances = ({ | ||
ddl, | ||
}: { | ||
ddl: string; | ||
}) => { | ||
return ddl.replace(/,\(/g, ', ('); | ||
}; |
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
6 changes: 5 additions & 1 deletion
6
...sivelyHeavilyNormalizeViewDdl/normalizations/removeDoubleParenthesisInJoinOnConditions.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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
/** | ||
* strip out the "double parenthesis" that SHOW CREATE likes to put on the "join on" statements | ||
*/ | ||
export const removeDoubleParenthesisInJoinOnConditions = ({ sql }: { sql: string }) => { | ||
export const removeDoubleParenthesisInJoinOnConditions = ({ | ||
sql, | ||
}: { | ||
sql: string; | ||
}) => { | ||
return sql.replace(/ on\(\((\w+\.\w+\s=\s\w+\.\w+)\)\)/g, ' on $1 '); // note: strictly only do this if matching the SHOW CREATE weird format of ` on((tableA.column = tableB.column))` | ||
}; |
16 changes: 13 additions & 3 deletions
16
...recursivelyHeavilyNormalizeViewDdl/normalizations/removeParenthesisFromWhereConditions.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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
/** | ||
* strip out all of the parenthesis (since SHOW CREATE adds them everywhere and thats too much to force users to maintain); unideal since it modifies the meaning, but this is only relevant for diffing | ||
*/ | ||
export const removeParenthesisFromWhereConditions = ({ flattenedSql }: { flattenedSql: string }) => { | ||
export const removeParenthesisFromWhereConditions = ({ | ||
flattenedSql, | ||
}: { | ||
flattenedSql: string; | ||
}) => { | ||
const whereCasing = !!flattenedSql.match(/\sWHERE\s/) ? 'WHERE' : 'where'; // determine if user is using upper case or lower case "where" | ||
const sqlSplitOnWhere = flattenedSql.split(whereCasing); | ||
if (sqlSplitOnWhere.length > 2) { | ||
// should not occur because the sql should have been flattened already | ||
throw new Error('found more than two parts of DDL after splitting on where; unexpected'); // fail fast | ||
throw new Error( | ||
'found more than two parts of DDL after splitting on where; unexpected', | ||
); // fail fast | ||
} | ||
const sqlWithoutParens = | ||
sqlSplitOnWhere.length === 2 | ||
? sqlSplitOnWhere[0] + '\n' + whereCasing + '\n' + sqlSplitOnWhere[1].replace(/[\(\)]/g, '') // tslint:disable-line prefer-template | ||
? sqlSplitOnWhere[0] + | ||
'\n' + | ||
whereCasing + | ||
'\n' + | ||
sqlSplitOnWhere[1].replace(/[\(\)]/g, '') // tslint:disable-line prefer-template | ||
: sqlSplitOnWhere[0]; // if no where clause, then nothing to replace | ||
return sqlWithoutParens; | ||
}; |
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
15 changes: 12 additions & 3 deletions
15
src/__nonpublished_modules__/sql-show-create-ddl/src/mysql/normalizeCreateDdlMysql/index.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
Oops, something went wrong.