lib/rom/sql/relation.rb in rom-sql-1.0.0 vs lib/rom/sql/relation.rb in rom-sql-1.0.1
- old
+ new
@@ -89,10 +89,15 @@
#
# @return [SQL::Relation]
#
# @api public
define_method(:by_pk) do |pk|
- where(schema[primary_key] => pk)
+ if primary_key.nil?
+ raise MissingPrimaryKeyError.new("Missing primary key for "\
+ ":#{ schema.name }")
+ else
+ where(schema[primary_key] => pk)
+ end
end
end
end
# @api private