Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

2 participants

@treydempsey

Include Sequel::SQL::AliasMethods in Sequel::Postgres::PGArray to allow aliasing PGArrays without having to use Sequel.as().

spec and extension updated

@treydempsey treydempsey Include Sequel::SQL::AliasMethods in Sequel::Postgres::PGArray to all…
…ow aliasing PGArrays without having to use Sequel.as()
c59f6ce
@jeremyevans
Owner

This looks good, I'll definitely merge it before the next release. Might not be right away as I'm currently on vacation.

We should probably consider doing the same for the other pg_* extensions where it makes sense.

@treydempsey

Pushed doc changes to wrong request. Ignore b590bb4

@jeremyevans jeremyevans merged commit b590bb4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 30, 2012
  1. @treydempsey

    Include Sequel::SQL::AliasMethods in Sequel::Postgres::PGArray to all…

    treydempsey authored
    …ow aliasing PGArrays without having to use Sequel.as()
Commits on Oct 2, 2012
  1. @treydempsey
This page is out of date. Refresh to see the latest.
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.