-
Notifications
You must be signed in to change notification settings - Fork 58
chore(common): merge Table and TableV2 #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dfb81d4
experiment: merge tables
stevensJourney 67c0a61
chore: merge tables
c3edb1b
chore: clean up
23c97bd
chore: changeset
cded655
fix: failing tests
e0e8dcb
chore: add comments
2a6a5b2
chore: use createTable:
9473cd6
fix: getter issue
e22e3ad
Merge branch 'main' into chore/merge-tables
DominicGBauer c2f56e4
chore: pr reverts
a3bed75
chore: pr reverts
642a89c
chore: update types
0cecf1b
chore: pr revert
54b3e77
Update demos/example-vite/src/index.js
DominicGBauer ad83220
Update demos/example-webpack/src/index.js
DominicGBauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
--- | ||
'@powersync/common': minor | ||
--- | ||
|
||
Merge `Table` and `TableV2` but kept `TableV2` to avoid making this a breaking change. |
This file contains hidden or 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 |
---|---|---|
|
@@ -11,4 +11,6 @@ | |
**/android/** | ||
**/assets/** | ||
**/bin/** | ||
**/ios/** | ||
**/ios/** | ||
|
||
pnpm-lock.yaml |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -35,4 +35,4 @@ yarn-error.log* | |
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
*.tsbuildinfo |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,60 @@ | ||
// https://www.sqlite.org/lang_expr.html#castexpr | ||
export enum ColumnType { | ||
TEXT = 'TEXT', | ||
INTEGER = 'INTEGER', | ||
REAL = 'REAL' | ||
} | ||
|
||
export interface ColumnOptions { | ||
name: string; | ||
type?: ColumnType; | ||
} | ||
|
||
export type BaseColumnType<T extends number | string | null> = { | ||
type: ColumnType; | ||
}; | ||
|
||
export type ColumnsType = Record<string, BaseColumnType<any>>; | ||
|
||
export type ExtractColumnValueType<T extends BaseColumnType<any>> = T extends BaseColumnType<infer R> ? R : unknown; | ||
|
||
const text: BaseColumnType<string | null> = { | ||
type: ColumnType.TEXT | ||
}; | ||
|
||
const integer: BaseColumnType<number | null> = { | ||
type: ColumnType.INTEGER | ||
}; | ||
|
||
const real: BaseColumnType<number | null> = { | ||
type: ColumnType.REAL | ||
}; | ||
|
||
// There is maximum of 127 arguments for any function in SQLite. Currently we use json_object which uses 1 arg per key (column name) | ||
// and one per value, which limits it to 63 arguments. | ||
export const MAX_AMOUNT_OF_COLUMNS = 63; | ||
|
||
export const column = { | ||
text, | ||
integer, | ||
real | ||
}; | ||
|
||
export class Column { | ||
constructor(protected options: ColumnOptions) {} | ||
|
||
get name() { | ||
return this.options.name; | ||
} | ||
|
||
get type() { | ||
return this.options.type; | ||
} | ||
|
||
toJSON() { | ||
return { | ||
name: this.name, | ||
type: this.type | ||
}; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.