luckyframework / luckyframework/avram

Better error catching on query types

Open
#155 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

improve error experience
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

The current type parsers are a bit funky and could use a little tightening up. This is best explained with some examples:

# Assuming `favorite_languages` is `Array(String)`
# This still compiles, but throws a `PQ::PQError`
UserQuery.new.favorite_languages("Crystal")

# Assuming `prices` is `Array(Float64)`
# This compiles, and is technically ok since this would be converted just fine.
# But should it?
ItemQuery.new.prices(["100"])

# Assuming `heart_count` is `Int32`
# This also compiles but is ok since it can be parsed
PostQuery.new.heart_count("5")
# This compiles, but throws an error
PostQuery.new.heart_count("five")

Since we want to focus on type safety, it's important that we lock these down the best we can, and use compile-time errors where possible.

ref: https://github.com/luckyframework/avram/pull/151#discussion_r305098032

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the query type parsers and the examples in this issue, then read the linked discussion in pull request 151 for the existing type-safety context. Establish which mismatched arguments should fail at compile time versus be converted, and verify that invalid values no longer surface as unexpected PQ::PQError exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.