Skip to content

Commit

Permalink
Defined primary_keys_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin authored and ciconia committed Feb 11, 2008
1 parent 7da2b43 commit 9b3d026
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/sequel_model/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def self.primary_key
def self.primary_key_hash(value)
{:id => value}
end


# returns the primary keys and their types as a hash
def self.primary_keys_hash
# TODO: make work for compound primary keys
{:id => "integer"}
end

# Sets primary key, regular and composite are possible.
#
# == Example:
Expand Down
4 changes: 2 additions & 2 deletions lib/sequel_model/relationships/join_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def create_table
# TODO: Inflect!, define a method to return primary_key as an array
instance_eval <<-JOINTABLE
db.create_table name.to_sym do
#{source_class.primary_key_def.reverse.join(" :#{Inflector.singularize(source_class.table_name)}_")}, :null => false
#{destination_class.primary_key_def.reverse.join(" :#{Inflector.singularize(destination_class.table_name)}_")}, :null => false
#{source_class.primary_keys_hash.reverse.join(" :#{Inflector.singularize(source_class.table_name)}_")}, :null => false
#{destination_class.primary_keys_hash.reverse.join(" :#{Inflector.singularize(destination_class.table_name)}_")}, :null => false
end
JOINTABLE
true
Expand Down

0 comments on commit 9b3d026

Please sign in to comment.