Changeset 4156
- Timestamp:
- 04/04/06 18:53:40 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4144 r4156 1 1 *SVN* 2 3 * Multiple fixes and optimizations in PostgreSQL adapter, allowing ruby-postgres gem to work properly. [ruben.nine@gmail.com] 2 4 3 5 * Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber] trunk/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
r3916 r4156 24 24 PGconn.connect(host, port, "", "", database, username, password), logger, config 25 25 ) 26 27 PGconn.translate_results = false if PGconn.respond_to? :translate_results= 26 28 27 29 pga.schema_search_path = config[:schema_search_path] || config[:schema_order] … … 64 66 true 65 67 end 66 rescue PGError 67 false 68 # postgres-pr raises a NoMethodError when querying if no conn is available 69 rescue PGError, NoMethodError 70 false 68 71 end 69 72 … … 340 343 private 341 344 BYTEA_COLUMN_TYPE_OID = 17 345 TIMESTAMPOID = 1114 346 TIMESTAMPTZOID = 1184 342 347 343 348 def configure_connection … … 356 361 def select(sql, name = nil) 357 362 res = execute(sql, name) 358 results = res.result 363 results = res.result 359 364 rows = [] 360 365 if results.length > 0 … … 364 369 row.each_index do |cel_index| 365 370 column = row[cel_index] 366 if res.type(cel_index) == BYTEA_COLUMN_TYPE_OID 367 column = unescape_bytea(column) 371 372 case res.type(cel_index) 373 when BYTEA_COLUMN_TYPE_OID 374 column = unescape_bytea(column) 375 when TIMESTAMPTZOID, TIMESTAMPOID 376 column = cast_to_time(column) 368 377 end 378 369 379 hashed_row[fields[cel_index]] = column 370 380 end … … 473 483 return "f" if value =~ /false/i 474 484 475 # Char/String type values476 return $1 if value =~ /^'(.*)'::(bpchar|text|character varying )$/485 # Char/String/Bytea type values 486 return $1 if value =~ /^'(.*)'::(bpchar|text|character varying|bytea)$/ 477 487 478 488 # Numeric values … … 486 496 return nil 487 497 end 498 499 # Only needed for DateTime instances 500 def cast_to_time(value) 501 return value unless value.class == DateTime 502 v = value 503 time_array = [v.year, v.month, v.day, v.hour, v.min, v.sec] 504 Time.send(Base.default_timezone, *time_array) rescue nil 505 end 488 506 end 489 507 end