3Small “will this compile?” puzzles from the typed query builder. Each prompt is short enough to adapt into a post; keep the answer for a follow-up.
9PureScript knows both the table schema and selected columns. Should this compile?
13 # select @"name, email"
17The inferred result row is:
20(name :: String, email :: String)
23PostgreSQL koan: which column betrays us only at runtime?
27It currently compiles and renders:
30SELECT name, email FROM users GROUP BY name
33PostgreSQL rejects `email`: every selected, non-aggregated expression must participate in the grouping. The type-level parser validates column existence but does not yet relate the SELECT expressions to GROUP BY.
35## Koan 2 — Nothing to insert
39Every column has a database-generated value:
42type Config = Table "config"
43 ( id :: Int # PrimaryKey # AutoIncrement
44 , active :: Boolean # Default True
45 , score :: Int # Default 0
48from (Proxy :: Proxy Config) # insert {}
51The empty record is exactly the right input. What SQL should it produce?
58INSERT INTO config DEFAULT VALUES
61The builder currently emits invalid SQL:
64INSERT INTO config () VALUES ()
67The input type is correct; the zero-column rendering branch is not.
69## Koan 3 — One means how many?
73What should `executeSqlOne` return when a query unexpectedly produces two rows?
76executeSqlOne query params connection
77 :: Aff (Either String (Maybe User))
821. `Left "expected at most one row"`
832. `Right (Just firstRow)`
88Today it returns `Right Nothing`. The implementation maps both zero rows and multiple rows to `Nothing`, so “not found” and “cardinality bug” are indistinguishable. A one-row API should preserve that invariant in its result or error channel.
90## Koan 4 — Half a second
94PostgreSQL returns this `TIME` value:
100How many milliseconds does the PureScript decoder put in `PGTime`?
104Today: `5`. Correct: `500`.
106The decoder parses the fractional digits directly as milliseconds. PostgreSQL fractions are decimal fractions of a second, so `.5`, `.50`, and `.500` must all decode to 500 milliseconds; longer fractions also need an explicit rounding or truncation rule.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list