astro:db
: db.run
queries are giving different responses from Astro Studio and from local files
#10970
Closed
1 task done
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When running queries with
db.run
, the result returned from the query differs on file and Astro DB databases. When running a query to a file database (local / using theASTRO_DATABASE_FILE
env var) the query rows are properly aliased with both the index and the alias for the selected column.Another observation I have noticed is that with the file-based database response, the
result.rows
values are not iterable where they are iterable from the Astro Studio version. This means that destructuring a row by[first, second, ...] = result.rows[0]
will not work on file-based database but will work with an Astro Studio DB.Assuming the following code was run:
The following is an example of what works with the different configurations:
value
Resultvalue
Resultconst { value } = result
const { 0: value } = result
const [value] = result
What's the expected result?
I would expect:
The values are to be accessible through both the alias and the index, no matter what type of database is being used through the Astro DB API.
Either both results to be iterable or neither to be iterable.
Link to Minimal Reproducible Example
https://github.com/timsexperiments/astro-sql-file-vs-remote
Participation
The text was updated successfully, but these errors were encountered: