-
Notifications
You must be signed in to change notification settings - Fork 256
print tablename in unique() error message #108
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,9 +166,15 @@ export class QueryImpl implements Query<GenericTableInfo> { | |
| { type: "executing"; queryId: number } | ||
| { type: "closed" } | ||
| { type: "consumed" }; | ||
|
||
private tableName: string; | ||
|
||
constructor(query: SerializedQuery) { | ||
this.state = { type: "preparing", query }; | ||
if (query.source.type === "FullTableScan") { | ||
this.tableName = query.source.tableName; | ||
} else { | ||
this.tableName = query.source.indexName.split(".")[0]; | ||
} | ||
} | ||
|
||
private takeQuery(): SerializedQuery { | ||
|
@@ -333,7 +339,7 @@ export class QueryImpl implements Query<GenericTableInfo> { | |
return null; | ||
} | ||
if (first_two_array.length === 2) { | ||
throw new Error(`unique() query returned more than one result: | ||
throw new Error(`unique() query returned more than one result from table ${this.tableName}: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thomasballinger what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @djbalin what do you think about printing indexName here instead of tableName? It'll give more information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nipunn1313 with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to me, it's table name that's immediately actionable and suggests the broken invariant, and nothing can that can be unique with an index that isn't unique on a table |
||
[${first_two_array[0]._id}, ${first_two_array[1]._id}, ...]`); | ||
} | ||
return first_two_array[0]; | ||
|
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.
just to avoid having multiple sources of truth, let's add a getter for this instead of stashing it here in the constructor
Not so big deal since it's
private
, but TypeScriptprivate
doesn't stop users from riting JavaScript that expectsthis.tableName
to be there