luckyframework / luckyframework/avram

Can't use postgres functions as default values if type isn't string

Open
#797 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/luckyframework/avram/blob/ac281f490a85283eaf8b74fd23357dd70a6d7f22/src/avram/migrator/columns/uuid_column.cr#L5

Default, currently, is type-limited in most cases to the type of the column. Time is the only exception. Because of this very problem custom handling was added to be able to pass in a particular symbol and it would translate that into a method call (:now). https://github.com/luckyframework/avram/blob/ac281f490a85283eaf8b74fd23357dd70a6d7f22/src/avram/migrator/columns/time_column.cr#L5

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 src/avram/migrator/columns/uuid_column.cr and compare its default handling with src/avram/migrator/columns/time_column.cr. Trace how column defaults are type-limited and how the :now symbol becomes a method call; the work is done when PostgreSQL function defaults can be represented for non-string column types.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.