Thanks, yeah, that totally makes sense, I suspected that this is just
SQLite's "fault" because it allows any type name. Cool, I didn't know that
you can specify types via method calls, I always just used `column :data,
:jsonb`.

Kind regards,
Janko

On Tue, Apr 4, 2017 at 1:08 AM, Jeremy Evans <[email protected]> wrote:

> On Sunday, April 2, 2017 at 6:09:43 PM UTC-7, Janko Marohnić wrote:
>>
>> Hello Jeremy,
>>
>> I was just working on a simple Sequel example, and I wrote this:
>>
>> require "sequel"
>>
>> DB = Sequel.sqlite
>>
>> DB.create_table :users do
>>   prmary_key :id
>>   column :name, :varchar
>> end
>>
>> # ...
>>
>> I was then getting "mismatched number of keys" errors when declaring
>> associations from the User model, and it took me time to realize that I
>> misspelled "primary_key". This is SQL that was sent to SQLite:
>>
>> CREATE TABLE `users` (`id` prmary_key, `name` varchar(255))
>>
>> I'm wondering if it's possible to be warned about this typo somehow.
>> Firstly, I'm surprised that this is valid SQLite statement, I thought
>> SQLite would raise an error for unknown database type. Secondly, I wasn't
>> aware that the `create_table` block uses method_missing and accepts any
>> method, I thought that it has a specified set of methods that it accepts.
>> Is there some additional functionality that `method_missing` enables here?
>>
>
> This is the way `create_table` has always worked, even before I took over
> maintenance.  It's what allows for nicer looking use of database-specific
> types.  Unfortunately, this can't be changed without breaking old
> migrations, and I've been hesitant to do that in the past.
>
> On most databases, this isn't a problem, as using an unrecognized type is
> an error.  However, SQLite allows the use of any type name, so this isn't
> an error on SQLite.
>
> Thanks,
> Jeremy
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sequel-talk" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/sequel-talk/dA2bjrxvc_0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to