Skip to content
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

Add support for stable ordering and dump of views. #1448

Merged
merged 2 commits into from Oct 28, 2023
Merged

Conversation

groue
Copy link
Owner

@groue groue commented Oct 28, 2023

This pull request fixes two runtime errors regarding database views (CREATE VIEW AS ...).

Requests created with withStableOrder() no longer throw when used on views:

// NEW: views with stable order
let request = Table("myView").all().withStableOrder()

Dumping the content of views with dumpTables() no longer throws:

// NEW: dump tables or views
try dbQueue.dumpTables(["myTable", "myView"])

By default, the rows of views are printed in the order specified by the view, which may be undefined. Pass stableOrder: true in order to guarantee a stable order, suitable for testing:

try db.execute("""
  CREATE VIEW playerName1
  AS SELECT name FROM player;

  CREATE VIEW playerName2
  AS SELECT name FROM player ORDER BY name;
  """)

// playerName1 rows are printed in an unspecified order.
// playerName2 rows are printed sorted by name.
try dbQueue.dumpTables(["playerName1", "playerName2"])

// playerName1 rows are printed in a stable order.
// playerName2 rows are printed in a stable order.
try dbQueue.dumpTables(["playerName1", "playerName2"], stableOrder: true)

@groue groue changed the base branch from master to development October 28, 2023 14:04
@groue groue merged commit aaad020 into development Oct 28, 2023
22 checks passed
@groue groue deleted the dev/dump-views branch October 28, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant