On May 13, 4:03 pm, cult hero <[email protected]> wrote:
> (As a heads up, I'm running Ruby 1.9.1 and Postgres via the native
> gem. I had to change the C code around a bit, but it's been working
> seemingly fine.)

First, a pox on you for using 1.9 specific syntax. :p

> Sequel::DatabaseError: PGError ERROR:  foreign key constraint
> "accounts_country_code_fkey" cannot be implemented
> DETAIL:  Key columns "country_code" and "code" are of incompatible
> types: integer and character.
> /opt/local/lib/ruby1.9/gems/1.9.1/gems/sequel-3.0.0/lib/sequel/
> adapters/postgres.rb:135:in `async_exec'

foreign_key is going to default to the Integer type unless you specify
a type via the :type option.  If you use the same type in both places,
it will probably be fine.

> It looks like it's setting the foreign key to an integer in accounts.
> Shouldn't it discover this automatically? And if not, is there any way
> to manually override this? I didn't see an obvious way looking through
> the rdocs. I know there are ways around it but... they're all kind of
> ugly.

No, I don't think it should.  The complexity and effort required is
not worth it for the minimal gain in functionality.  Just specify
the :type option to foreign_key and it should work fine.  If you want
to send in a patch that does this, I'll consider it, but there are
some corner cases it needs to handle (self referential foreign keys
for one).

> One last bit. I tried creating the more generic migrations using
> "String :first_name, size: 32" rather than
> "column :first_name, :varchar, size: 32" but in Postgres String =
> "text" rather than the expect "character varying." Is this a bug or is
> this by design?

This is by design.  Unlike most databases, text is the preferred
character string type in PostgreSQL (http://www.postgresql.org/docs/
8.3/static/datatype-character.html).  I'd prefer to use an arbitrary
length type for String on all databases, but arbitrary length string
types on other databases often have quirks.  The reason I'd prefer to
use an arbitrary length type for String is that a ruby String can be
an arbitrary length, and the whole point of the the generic types is
to give you a database type that can hold any object of the given ruby
class.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to