Skip to content

Include Sequel::SQL::AliasMethods in Sequel::Postgres::PGArray extension #563

Merged
merged 2 commits into from Oct 17, 2012
View
2 lib/sequel/database/schema_generator.rb
@@ -177,7 +177,7 @@ def has_column?(name)
# :concurrently :: Create the index concurrently, so it doesn't block
# operations on the table while the index is being
# built.
- # :op_class :: Use a specific operator class in the index.
+ # :opclass :: Use a specific operator class in the index.
#
# Microsoft SQL Server specific options:
#
View
2 lib/sequel/extensions/pg_array.rb
@@ -99,6 +99,8 @@ module Sequel
module Postgres
# Represents a PostgreSQL array column value.
class PGArray < DelegateClass(Array)
+ include Sequel::SQL::AliasMethods
+
ARRAY = "ARRAY".freeze
DOUBLE_COLON = '::'.freeze
EMPTY_BRACKET = '[]'.freeze
View
4 spec/extensions/pg_array_spec.rb
@@ -231,6 +231,10 @@
proc{@db.typecast_value(:integer_array, {})}.should raise_error(Sequel::InvalidValue)
end
+ it "should support SQL::AliasMethods" do
+ @db.select(Sequel.pg_array([1], :integer).as(:col1)).sql.should == 'SELECT ARRAY[1]::integer[] AS col1'
+ end
+
it "should support registering custom array types" do
Sequel::Postgres::PGArray.register('foo')
@db.typecast_value(:foo_array, []).should be_a_kind_of(Sequel::Postgres::PGArray)
Something went wrong with that request. Please try again.