Skip to content

Commit 4327b75

Browse files
committed
Validate schema again, including number of columns.
1 parent a2538f6 commit 4327b75

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/powersync/lib/src/database/native/native_powersync_database.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ class PowerSyncDatabaseImpl
261261
if (disconnecter != null) {
262262
throw AssertionError('Cannot update schema while connected');
263263
}
264+
schema.validate();
264265
this.schema = schema;
265266
return updateSchemaInIsolate(database, schema);
266267
}

packages/powersync/lib/src/schema.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ class Schema {
1111
const Schema(this.tables);
1212

1313
Map<String, dynamic> toJson() => {'tables': tables};
14+
15+
void validate() {
16+
for (var table in tables) {
17+
table.validate();
18+
}
19+
}
1420
}
1521

1622
/// A single table in the schema.
@@ -106,6 +112,12 @@ class Table {
106112

107113
columnNames.add(column.name);
108114
}
115+
116+
if (columns.length > 63) {
117+
throw AssertionError(
118+
"Table $name has ${columns.length} columns, maximum is 63.");
119+
}
120+
109121
Set<String> indexNames = {};
110122

111123
for (var index in indexes) {

0 commit comments

Comments
 (0)