lib/og/store/psql.rb in og-0.17.0 vs lib/og/store/psql.rb in og-0.18.0
- old
+ new
@@ -77,10 +77,18 @@
options[:port], nil, nil,
options[:name],
options[:user].to_s,
options[:password].to_s
)
+
+ schema_order = options[:schema_order]
+ encoding = options[:encoding]
+ min_messages = options[:min_messages]
+
+ @conn.exec("SET search_path TO #{schema_order}") if schema_order
+ @conn.exec("SET client_encoding TO '#{encoding}'") if encoding
+ @conn.exec("SET client_min_messages TO '#{min_messages}'") if min_messages
rescue => ex
# gmosx: any idea how to better test this?
if ex.to_s =~ /database .* does not exist/i
Logger.info "Database '#{options[:name]}' not found!"
self.class.create(options)
@@ -115,13 +123,13 @@
end
private
def create_table(klass)
- columns = columns_for_class(klass)
+ fields = fields_for_class(klass)
- sql = "CREATE TABLE #{klass::OGTABLE} (#{columns.join(', ')}"
+ sql = "CREATE TABLE #{klass::OGTABLE} (#{fields.join(', ')}"
# Create table constrains.
if klass.__meta and constrains = klass.__meta[:sql_constrain]
sql << ", #{constrains.join(', ')}"
@@ -178,27 +186,27 @@
def drop_table(klass)
super
exec "DROP SEQUENCE #{klass::OGSEQ}"
end
- def create_column_map(klass)
+ def create_field_map(klass)
res = @conn.exec "SELECT * FROM #{klass::OGTABLE} LIMIT 1"
map = {}
- for column in res.fields
- map[column.intern] = res.fieldnum(column)
+ for field in res.fields
+ map[field.intern] = res.fieldnum(field)
end
return map
ensure
res.clear if res
end
def read_prop(p, col)
if p.klass.ancestors.include?(Integer)
- return "res.getvalue(row, #{col} + offset).to_i"
+ return "#{self.class}.parse_int(res.getvalue(row, #{col} + offset))"
elsif p.klass.ancestors.include?(Float)
- return "res.getvalue(row, #{col} + offset).to_f"
+ return "#{self.class}.parse_float(res.getvalue(row, #{col} + offset))"
elsif p.klass.ancestors.include?(String)
return "res.getvalue(row, #{col} + offset)"
elsif p.klass.ancestors.include?(Time)
return "#{self.class}.parse_timestamp(res.getvalue(row, #{col} + offset))"
elsif p.klass.ancestors.include?(Date)