-
Notifications
You must be signed in to change notification settings - Fork 8
[TILES-V2-3]: implement postgres functions for row, column and table operations #974
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
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 772 Passed, 0 Skipped, 2m 47.68s Total Time 🔻 Code Coverage Decreases vs Default Branch (1)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
tested new dependencies and existing integration tests 👍
new tiles pg functions look good
Merge activity
|
30bd0a2
to
6ae2644
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: ULID Generation Inconsistency Breaks Monotonicity
Inconsistent ULID generation between createTableRow
and createTableRows
. createTableRow
uses monotonicFactory()
but creates it inside the function (defeating its purpose for calls across time), while createTableRows
uses the global ulid()
function. This inconsistency and incorrect usage breaks monotonic ordering guarantees for row IDs, particularly when creating multiple rows.
packages/backend/src/models/tiles/pg/table-row-functions.ts#L26-L59
plumber/packages/backend/src/models/tiles/pg/table-row-functions.ts
Lines 26 to 59 in 6ae2644
}: CreateRowInput): Promise<TableRowItem> => { | |
const ulid = monotonicFactory() | |
try { | |
const res = await tilesClient(tableId) | |
.insert({ | |
...data, | |
rowId: ulid(), | |
}) | |
.returning('*') | |
return res[0] | |
} catch (e: unknown) { | |
logger.error(e) | |
throw e | |
} | |
} | |
export const createTableRows = async ({ | |
tableId, | |
dataArray, | |
}: CreateRowsInput): Promise<string[]> => { | |
try { | |
const rows = dataArray.map((data, i) => ({ | |
rowId: ulid(), | |
...data, | |
// manually bumping the createdAt timestamp to ensure that row order is preserved | |
createdAt: new Date(Date.now() + i), | |
})) | |
const res = await tilesClient(tableId).insert(rows).returning(['rowId']) | |
return res.map((row) => row.rowId) | |
} catch (e: unknown) { | |
logger.error(e) | |
throw e | |
} | |
} |
Bug: Column Type Mismatch Bug
Inconsistent column types: createTable
uses string
for columns, while createTableColumns
uses text
. This creates a type mismatch between initially created columns and later added columns.
packages/backend/src/models/tiles/pg/table-functions.ts#L5-L7
table.string('rowId').primary() | |
columnIds.forEach((columnId) => { | |
table.string(columnId) |
packages/backend/src/models/tiles/pg/table-column-functions.ts#L5-L6
columnIds.forEach((columnId) => { | |
table.text(columnId) |
BugBot free trial expires on June 9, 2025
You have used $0.00 of your $1.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
Changes
Added PostgreSQL support for Tiles with streaming capabilities and ULID for row IDs.
What changed?
pg-query-stream
andulid
to support PostgreSQL streaming and monotonic ID generationtable-functions.ts
- For creating tablestable-column-functions.ts
- For managing table columnstable-row-functions.ts
- For CRUD operations on table rowstypes.ts
How to test?
npm install