singleStoreCombineStatements() — drizzle-orm Function Reference
Architecture documentation for the singleStoreCombineStatements() function in statementCombiner.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD b8879ab0_6fb8_f5fc_937a_31ddbde3804f["singleStoreCombineStatements()"] 21a395af_9564_2dbd_9ea9_060ad50ee7a0["statementCombiner.ts"] b8879ab0_6fb8_f5fc_937a_31ddbde3804f -->|defined in| 21a395af_9564_2dbd_9ea9_060ad50ee7a0 d4992b27_bf78_8099_5134_750cef1c518c["applySingleStoreSnapshotsDiff()"] d4992b27_bf78_8099_5134_750cef1c518c -->|calls| b8879ab0_6fb8_f5fc_937a_31ddbde3804f 8bb59420_0ac2_e04d_e01a_47343f29242b["prepareSingleStoreRecreateTable()"] b8879ab0_6fb8_f5fc_937a_31ddbde3804f -->|calls| 8bb59420_0ac2_e04d_e01a_47343f29242b style b8879ab0_6fb8_f5fc_937a_31ddbde3804f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-kit/src/statementCombiner.ts lines 472–597
export const singleStoreCombineStatements = (
statements: JsonStatement[],
json2: SingleStoreSchemaSquashed,
) => {
const newStatements: Record<string, JsonStatement[]> = {};
for (const statement of statements) {
if (
statement.type === 'alter_table_alter_column_set_type'
|| statement.type === 'alter_table_alter_column_set_notnull'
|| statement.type === 'alter_table_alter_column_drop_notnull'
|| statement.type === 'alter_table_alter_column_drop_autoincrement'
|| statement.type === 'alter_table_alter_column_set_autoincrement'
|| statement.type === 'alter_table_alter_column_drop_pk'
|| statement.type === 'alter_table_alter_column_set_pk'
|| statement.type === 'create_composite_pk'
|| statement.type === 'alter_composite_pk'
|| statement.type === 'delete_composite_pk'
) {
const tableName = statement.tableName;
const statementsForTable = newStatements[tableName];
if (!statementsForTable) {
newStatements[tableName] = prepareSingleStoreRecreateTable(json2.tables[tableName]);
continue;
}
if (!statementsForTable.some(({ type }) => type === 'recreate_table')) {
const wasRename = statementsForTable.some(({ type }) =>
type === 'rename_table' || type === 'alter_table_rename_column'
);
const preparedStatements = prepareSingleStoreRecreateTable(json2.tables[tableName]);
if (wasRename) {
newStatements[tableName].push(...preparedStatements);
} else {
newStatements[tableName] = preparedStatements;
}
continue;
}
continue;
}
if (
(statement.type === 'alter_table_alter_column_drop_default'
|| statement.type === 'alter_table_alter_column_set_default') && statement.columnNotNull
) {
const tableName = statement.tableName;
const statementsForTable = newStatements[tableName];
if (!statementsForTable) {
newStatements[tableName] = prepareSingleStoreRecreateTable(json2.tables[tableName]);
continue;
}
if (!statementsForTable.some(({ type }) => type === 'recreate_table')) {
const wasRename = statementsForTable.some(({ type }) => type === 'rename_table');
const preparedStatements = prepareSingleStoreRecreateTable(json2.tables[tableName]);
if (wasRename) {
newStatements[tableName].push(...preparedStatements);
} else {
newStatements[tableName] = preparedStatements;
}
continue;
}
continue;
}
if (statement.type === 'alter_table_add_column' && statement.column.primaryKey) {
const tableName = statement.tableName;
const statementsForTable = newStatements[tableName];
if (!statementsForTable) {
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does singleStoreCombineStatements() do?
singleStoreCombineStatements() is a function in the drizzle-orm codebase, defined in drizzle-kit/src/statementCombiner.ts.
Where is singleStoreCombineStatements() defined?
singleStoreCombineStatements() is defined in drizzle-kit/src/statementCombiner.ts at line 472.
What does singleStoreCombineStatements() call?
singleStoreCombineStatements() calls 1 function(s): prepareSingleStoreRecreateTable.
What calls singleStoreCombineStatements()?
singleStoreCombineStatements() is called by 1 function(s): applySingleStoreSnapshotsDiff.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free