Sha256: e62e6bb722f169efe35d9e5d6945cd22711b518585e0812b0e0d5031bb3c9e14

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

TODO
  o Create an abstract PgConnBase and have PgStmts (writes statements to array)
    and PgConn (sends statements to server) classes derived from it
  o fix silent
  o fix fail
  o A PgConn.new with a block. Useful for temporary database connections (a
    rather specialized use-case, though)
  o A "#bag" method that allows duplicate IDs
  o Generalize #set using :element_type option. This makes #table a special case of #set
  o Maybe grant/revoke methods. Problem that there is large number of variations
      # :callseq:
      #   grant(role, to_role)
      #   grant(privilege, subject, to_role)
      def grant(role, to_role)
        # 
        conn.exec "grant #{role} to #{to_role}"
      end
  o Allow a :type argument to all query methods that can be used to specify the
    composition of anonymous record types


REFACTOR
  #!/usr/bin/env ruby

  module PgConn
    # Global PgConn instance
    def self.instance() @@pg_conn_instance ||= PgConn.new end
    def self.instance=(pg_conn) @@pg_conn_instance = pg_conn end

    def self.connect(*args)
      conn = PgConn.new(*args)
      @@pg_conn_instance ||= conn
      conn
    end

    def self.new() raise "TODO" end

    class PgConn
      include PgQuery
      include PgTransaction
      attr_reader :schema
      attr_reader :role
      attr_reader :rdbms
    end

    class Connection
      attr_reader :query
      attr_reader :transaction
      attr_reader :schema
      attr_reader :role
      attr_reader :rdbms
    end
  end

  module SchemaMethods
    def conn() "schema_methods_conn" end
    def schema_doit() puts "#{conn}: schema_doit" end
  end

  class SchemaMethodsObject
    include SchemaMethods
    def conn() "schema_methods_object_conn" end
    def doit() schema_doit end
  end

  s = SchemaMethodsObject.new
  s.doit
  s.schema_doit

  # Example
  include PgConn
  p values "select * from t" # Connection is set up by default

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pg_conn-0.4.0 TODO
pg_conn-0.3.7 TODO
pg_conn-0.3.6 TODO
pg_conn-0.3.5 TODO
pg_conn-0.3.4 TODO
pg_conn-0.3.3 TODO
pg_conn-0.3.2 TODO
pg_conn-0.3.1 TODO