Code Monkey home page Code Monkey logo

Comments (5)

AlfonsoUceda avatar AlfonsoUceda commented on May 26, 2024

I was researching this issue with the example proposed by @jodosha in #134

I was trying to set the default value if the value from database is nil and default isn't nil in https://github.com/lotus/model/blob/master/lib/lotus/model/mapping/coercer.rb#L69 but the "compilation" with this issue turn me on crazy.

an example:

in the from_record method, record is a hash

{id: 1, name: 'Luca', admin: nil}

and then a Hash is constructed in the line before commented, with the values coerced and used to build a new entity.

Do you think it's useful something like this?

from model.

fidothe avatar fidothe commented on May 26, 2024

There's a bigger problem here: imagine that the admin column in the example above is non-NULLable in addition to having a default set. Currently, if you don't explicitly set the value in the entity then Lotus sends column => nil on serialisation. This causes Postgres, at least, to choke and error - you can't explicitly set a non-nullable value to null.

It also suggests that we're explicitly setting columns with default values to null when we might expect them to use the column default

from model.

theCrab avatar theCrab commented on May 26, 2024

@jodosha @AlfonsoUceda

$ LOTUS_ENV=test bundle exec lotus db prepare
Unsupported ruby class used as database type: Boolean (Sequel::Error)

How did you define the Sequel's TrueClass FalseClass?

from model.

jodosha avatar jodosha commented on May 26, 2024

@theCrab We use Sequel as migration engine. The list of Ruby types is defined here: http://lotusrb.org/guides/migrations/create-table/ 😸

from model.

jodosha avatar jodosha commented on May 26, 2024

Closing this for now, as we want to narrow the scope as much as possible before to hit 1.0.

from model.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.