Skip to content
Discussion options

You must be logged in to vote

You're not missing anything. Relations are lazy, so every fetch or query over one runs it again and gen_random_uuid() draws new values each time. Since 2.0.0 the conventional way is rel.materialize(). It runs the relation once and keeps the rows, and every later fetch, derived relation and SQL query that names it sees the same ids. I checked this on 2.0.0 with a self join on id, which gives one row. to_table() is the right choice when the rows should live in the database, and building on relations is fine practice as long as anything non deterministic is materialized first. Note that in 2.0 printing a plain relation also runs it, so repr no longer shows a stable value.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by WarmCyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants