Skip to content

Commit ca9bafe

Browse files
authored
Remove Compiled* schema objects (#73)
1 parent 80f5af8 commit ca9bafe

11 files changed

Lines changed: 261 additions & 299 deletions

File tree

PowerSync/PowerSync.Common/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## 0.1.3
44

5+
- **Breaking:** Made `Table.Name` non-nullable (default ""). This change may affect 0% of users, but it is technically a breaking change.
56
- Add support for loading custom SQLite extensions via `MDSQLiteOptions.Extensions`.
67
- Fix streaming sync retry loop reconnecting with no delay after an exception, ignoring `RetryDelayMs`.
8+
- (internal) Remove `Compiled*` classes in favor of working with `Table` and `Schema` objects directly.
79

810
## 0.1.2
911

PowerSync/PowerSync.Common/Client/PowerSyncDatabase.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public interface IPowerSyncDatabase : ICloseableAsync
130130
public class PowerSyncDatabase : IPowerSyncDatabase
131131
{
132132
public IDBAdapter Database { get; protected set; }
133-
private CompiledSchema schema;
133+
private Schema schema;
134134

135135
private const int DEFAULT_WATCH_THROTTLE_MS = 30;
136136
private static readonly Regex POWERSYNC_TABLE_MATCH = new Regex(@"(^ps_data__|^ps_data_local__)", RegexOptions.Compiled);
@@ -199,7 +199,7 @@ public PowerSyncDatabase(PowerSyncDatabaseOptions options)
199199
Closed = false;
200200
Ready = false;
201201

202-
schema = options.Schema.Compile();
202+
schema = options.Schema;
203203
SdkVersion = "";
204204

205205
remoteFactory = options.RemoteFactory ?? (connector => new Remote(connector));
@@ -402,23 +402,22 @@ protected async Task ResolveOfflineSyncStatus()
402402
/// </summary>
403403
public async Task UpdateSchema(Schema schema)
404404
{
405-
CompiledSchema compiledSchema = schema.Compile();
406405
if (syncStreamImplementation != null)
407406
{
408407
throw new Exception("Cannot update schema while connected");
409408
}
410409

411410
try
412411
{
413-
compiledSchema.Validate();
412+
schema.Validate();
414413
}
415414
catch (Exception ex)
416415
{
417416
Logger.LogWarning("Schema validation failed. Unexpected behavior could occur: {Exception}", ex);
418417
}
419418

420-
this.schema = compiledSchema;
421-
await Database.Execute("SELECT powersync_replace_schema(?)", [compiledSchema.ToJSON()]);
419+
this.schema = schema;
420+
await Database.Execute("SELECT powersync_replace_schema(?)", [JsonConvert.SerializeObject(schema)]);
422421
await Database.RefreshSchema();
423422
Events.Emit(new PowerSyncDBEvents.SchemaChangedEvent(schema));
424423
}

PowerSync/PowerSync.Common/DB/Schema/ColumnJSON.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace PowerSync.Common.DB.Schema;
2+
3+
public enum ColumnType
4+
{
5+
Text,
6+
Integer,
7+
Real,
8+
/// <summary>
9+
/// Infers the column type based on the associated property's PropertyType.
10+
/// <b>NB:</b> `ColumnType.Inferred` can only be used when using the <see cref="Attributes" /> syntax.
11+
/// </summary>
12+
Inferred
13+
}

PowerSync/PowerSync.Common/DB/Schema/CompiledSchema.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

PowerSync/PowerSync.Common/DB/Schema/CompiledTable.cs

Lines changed: 0 additions & 149 deletions
This file was deleted.

PowerSync/PowerSync.Common/DB/Schema/IndexJSON.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

PowerSync/PowerSync.Common/DB/Schema/IndexedColumnJSON.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)