Hanami Docs error (postgres UUID & Entity)


#1

Seems like they are typos, confused my newbie brain when following along.

In: http://hanamirb.org/guides/models/postgresql/
UUID as Primary Key

    create_table :project_files do
      column :id, 'uuid', null: false, default: Hanami::Model::Sql.function(:uuid_generate_v4)
      column :name, String
    end

should be

primary_key :id, 'uuid', null: false, default: Hanami::Model::Sql.function(:uuid_generate_v4)

When it’s using column, :id is correctly a UUID but repo cannot find by id

Hanami::Model::MissingPrimaryKeyError: Missing primary key for :teachers
    /usr/local/lib/ruby/gems/2.4.0/gems/hanami-model-1.0.0/lib/hanami/repository.rb:404:in `rescue in find'
    /usr/local/lib/ruby/gems/2.4.0/gems/hanami-model-1.0.0/lib/hanami/repository.rb:402:in `find'

It’s fixed when using primary_key

Quick demo: https://github.com/billiamliu/test_hanami_postgres
$ rake test


In: http://hanamirb.org/guides/models/entities/

Custom schema takes precedence over automatic schema. If we use custom schema, we need to manually add all the new columns from the corresponding SQL database table.

Should be:

Custom schema takes precedence over automatic schema. If we use custom schema, we need to manually add all the new columns to the corresponding SQL database table.


#2

@billiam Thank you very much. Fixed the guides: https://github.com/hanami/hanami.github.io/commit/9f620eb4f7676493fa12a23db62b1f0cf46a6d48


Regarding the entity suggested fix, we use “from” because you want to map in your entity the columns that you have in your database.