geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Real number not always a good choice. #247

Closed danfinlay closed 9 years ago

danfinlay commented 9 years ago

Is there a way to choose other number types for the Postgres adapter?

Currently if I create a migration or scaffold a column to use the type number, Model creates a Postgres column of type real.

This is maybe a good general choice, but when my columns can represent relational IDs (the way they do when using autoIncrementId = true in the config), this means imprecise relationships!

This took me a while to debug. I think I'm going to just set the data types manually for the moment, but is there a way to dictate number types within model in the future?

danfinlay commented 9 years ago

Oh silly me, I should be using the int type.

danfinlay commented 9 years ago

Actually, this DOES seem to be a problem. If I force a data-type to INTEGER, it doesn't really matter, because all Model has is a belongsTo, not an integer declaration, since it's just a relationship, not an attribute. And when the results come back, even from a query that returns valid SQL results, Model seems to be dropping results that don't have "expected" data types.

Maybe I can set an attribute that is also used as a belongsTo key, and it will force the data type..

danfinlay commented 9 years ago

Sorry, long day, I think I was trolling myself :P