aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql
Commit message (Collapse)AuthorAgeFilesLines
* Rails 5.1 point type should not raise exception if empty string is provided ↵bUg2016-05-151-0/+2
| | | | as value
* Treat blank comments as no comment for indexesRyuta Kamizono2016-04-291-1/+1
| | | | | | Follow up of 1683410. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Add Expression Indexes and Operator Classes support for PostgreSQLRyuta Kamizono2016-04-241-15/+20
| | | | | | | | | | | | | | | | Example: create_table :users do |t| t.string :name t.index 'lower(name) varchar_pattern_ops' end Fixes #19090. Fixes #21765. Fixes #21819. Fixes #24359. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Move `require 'ipaddr'` in `postgresql/oid/cidr.rb`Ryuta Kamizono2016-04-241-0/+2
| | | | `IPAddr` is used in `OID::Cidr`.
* Fix `test_blank_columns_created_in_block`Ryuta Kamizono2016-04-201-1/+1
| | | | Follow up to 1683410.
* Merge pull request #23622 from kamipo/primary_key_should_be_not_nullJeremy Daer2016-04-181-1/+1
|\ | | | | | | Primary key should be `NOT NULL`
| * Primary key should be `NOT NULL`Ryuta Kamizono2016-03-121-1/+1
| | | | | | | | | | | | | | Follow up to #18228. In MySQL and PostgreSQL, primary key is to be `NOT NULL` implicitly. But in SQLite it must be specified `NOT NULL` explicitly.
* | Database comments: switch to keyword args for new table optionsJeremy Daer2016-04-181-16/+16
| | | | | | | | | | | | * Switch to keyword args where we can without breaking compat. * Use add_table_options! for :options, too. * Some code polish.
* | Add support for specifying comments for tables, columns, and indexes.Andrey Novikov2016-04-161-8/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | Comments are specified in migrations, stored in database itself (in its schema), and dumped into db/schema.rb file. This allows to generate good documentation and explain columns and tables' purpose to everyone from new developers to database administrators. For PostgreSQL and MySQL only. SQLite does not support comments at the moment. See docs for PostgreSQL: http://www.postgresql.org/docs/current/static/sql-comment.html See docs for MySQL: http://dev.mysql.com/doc/refman/5.7/en/create-table.html
* | Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-121-2/+2
| | | | | | | | | | | | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* | Move `@quoted_{column|table}_names` cache up to the abstract adapterRyuta Kamizono2016-03-311-4/+4
|/
* Merge pull request #24054 from kamipo/extract_default_primary_keyRafael França2016-03-111-10/+7
|\ | | | | Extract `default_primary_key?` to refactor `column_spec_for_primary_key`
| * Extract `default_primary_key?` to refactor `column_spec_for_primary_key`Ryuta Kamizono2016-03-111-10/+7
| |
* | Merge pull request #24087 from kamipo/dump_bigint_instead_of_integer_limit_8Rafael França2016-03-111-4/+0
|\ \ | | | | | | Dump `bigint` instead of `integer` with `limit: 8` for schema dumper
| * | Dump `bigint` instead of `integer` with `limit: 8` for schema dumperRyuta Kamizono2016-03-111-4/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby create_table "big_numbers", force: :cascade do |t| t.integer "bigint_column", limit: 8 end ``` After: ```ruby create_table "big_numbers", force: :cascade do |t| t.bigint "bigint_column" end ```
* | Merge pull request #23677 from kamipo/passing_table_name_to_column_initializeRafael França2016-03-112-5/+5
|\ \ | |/ |/| Passing `table_name` to `Column#initialize` to avoid `instance_variable_set`
| * Passing `table_name` to `Column#initialize` to avoid `instance_variable_set`Ryuta Kamizono2016-03-081-5/+3
| |
| * Initialize `column.table_name` immediately for `column.serial?` correctly ↵Ryuta Kamizono2016-03-082-3/+5
| | | | | | | | | | | | | | | | working Currently the results of `column.serial?` is not correct. For `column.serial?` correctly working, initialize `column.table_name` immediately.
* | Merge pull request #23958 from kamipo/fix_bigserial_appears_with_limit_8Rafael França2016-03-111-0/+4
|\ \ | |/ |/| Fix bigserial appears with limit 8 for schema dumper
| * Fix bigserial appears with limit 8 for schema dumperRyuta Kamizono2016-03-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ```ruby create_table "postgresql_big_serials", force: :cascade do |t| t.bigserial "seq", limit: 8, null: false end ``` After: ```ruby create_table "postgresql_big_serials", force: :cascade do |t| t.bigserial "seq", null: false end ```
* | Remove outdated comment [ci skip]Ryuta Kamizono2016-03-041-1/+0
|/ | | | Currently column options handled by the type map in Rails 4.2.
* Exclude `:name` and `:type` from `prepare_column_options`Ryuta Kamizono2016-02-291-1/+1
| | | | Actually `:name` and `:type` are not column options.
* eliminate warnings about multiple primary keys on habtm join tablesAaron Patterson2016-02-191-1/+1
| | | | | | | | habtm join tables commonly have two id columns and it's OK to make those two id columns a primary key. This commit eliminates the warnings for join tables that have this setup. ManageIQ/manageiq#6713
* `schema_type` returns symbol rather than stringRyuta Kamizono2016-02-081-3/+3
| | | | | | | | | A return value of `schema_type` is used by: 1. primary key type: using as `symbol.inspect` 2. normal column type: using as `symbol.to_s` It is better to return symbol.
* Extract `ExplainPrettyPrinter` to appropriate filesRyuta Kamizono2016-02-012-38/+43
|
* `OID::Money.precision` is unused since #15239Ryuta Kamizono2016-01-311-2/+0
| | | | | | | | p PostgreSQLAdapter::OID::Money.precision # => 19 p PostgreSQLAdapter::OID::Money.new.precision # => nil
* Revert "Merge pull request #23346 from kamipo/refactor_oid_money_precision"Rafael Mendonça França2016-01-301-4/+2
| | | | | | | This reverts commit ff835f90800a3e4122d64606cb328908c2e0e071, reversing changes made to c4d85dfbc71043e2a746acd310e32f4f04db801a. Reason: This broke the tests. We will add back after investigated.
* Refactor `OID::Money.precision`Ryuta Kamizono2016-01-301-2/+4
|
* Clarify DatabaseStatements#execute docs re: memory usage.James Coleman2016-01-221-0/+2
|
* Merge pull request #20005 from kamipo/default_expression_supportRafael França2016-01-162-11/+8
|\ | | | | Add `:expression` option support on the schema default
| * Add expression support on the schema defaultRyuta Kamizono2016-01-132-11/+8
| | | | | | | | | | | | | | | | Example: create_table :posts do |t| t.datetime :published_at, default: -> { 'NOW()' } end
* | `sql_for_insert` returns values for passing to `exec_insert`Ryuta Kamizono2016-01-151-12/+8
|/
* Refactor tz aware types, add support for PG rangesSean Griffin2016-01-082-1/+12
| | | | | | | | | | | | | | | | | This is an alternate implementation to #22875, that generalizes a lot of the logic that type decorators are going to need, in order to have them work with arrays, ranges, etc. The types have the ability to map over a value, with the default implementation being to just yield that given value. Array and Range give more appropriate definitions. This does not automatically make ranges time zone aware, as they need to be added to the `time_zone_aware` types config, but we could certainly make that change if we feel it is appropriate. I do think this would be a breaking change however, and should at least have a deprecation cycle. Closes #22875. /cc @matthewd
* Merge pull request #22973 from kamipo/fix_select_values_method_signatureRafael França2016-01-081-2/+2
|\ | | | | Fix `select_values` method signature for consistency
| * Fix `select_values` method signature for consistencyRyuta Kamizono2016-01-081-2/+2
| |
* | `{update|delete}_sql` are almost the same as `{update|delete}`Ryuta Kamizono2016-01-081-5/+0
|/ | | | Simply `{update|delete}_sql` aliases to `{update|delete}`.
* Refactor `connection.insert_sql`Ryuta Kamizono2016-01-071-16/+2
| | | | `connection.insert_sql` is almost the same as `connection.insert`.
* Fix `connection#create` in PG adapterRyuta Kamizono2016-01-051-4/+0
| | | | | | Originally `connection#create` had aliased to `connection#insert` in PG adapter. But it was broken by #7447. Re-alias `create` to `insert` for fixing it.
* Handle specified schemas when removing a Postgres indexGrey Baker2015-12-181-3/+16
|
* Support passing the schema name prefix to `conenction.indexes`Grey Baker2015-12-171-9/+12
| | | | | | | Support passing the schema name as a prefix to table name in `ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would be considered a full part of the index name, and only the schema in the current search path would be considered.
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-1/+16
| | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Do not cache prepared statements that are unlikely to have cache hitsSean Griffin2015-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, Rails makes no differentiation between whether a query uses bind parameters, and whether or not we cache that query as a prepared statement. This leads to the cache populating extremely fast in some cases, with the statements never being reused. In particular, the two problematic cases are `where(foo: [1, 2, 3])` and `where("foo = ?", 1)`. In both cases we'll end up quoting the values rather than using a bind param, causing a cache entry for every value ever used in that query. It was noted that we can probably eventually change `where("foo = ?", 1)` to use a bind param, which would resolve that case. Additionally, on PG we can change our generated query to be `WHERE foo = ANY($1)`, and pass an array for the bind param. I hope to accomplish both in the future. For SQLite and MySQL, we still end up preparing the statements anyway, we just don't cache it. The statement will be cleaned up after it is executed. On postgres, we skip the prepare step entirely, as an API is provided to execute with bind params without preparing the statement. I'm not 100% happy on the way this ended up being structured. I was hoping to use a decorator on the visitor, rather than mixing a module into the object, but the way Arel has it's visitor pattern set up makes it very difficult to extend without inheritance. I'd like to remove the duplication from the various places that are extending it, but that'll require a larger restructuring of that initialization logic. I'm going to take another look at the structure of it soon. This changes the signature of one of the adapter's internals, and will require downstream changes from third party adapters. I'm not too worried about this, as worst case they can simply add the parameter and always ignore it, and just keep their previous behavior. Fixes #21992.
* Move the methods for schema dumping into `{mysql,postgresql}/schema_dumper.rb`Ryuta Kamizono2015-10-131-0/+54
| | | | | Current master branch includes many schema dumping improvements. It extract these features to the appropriate files.
* Wrong usage of 'a' in docs fixed [ci skip]Mehmet Emin İNAÇ2015-10-031-1/+1
|
* Merge pull request #20317Sean Griffin2015-09-231-11/+7
|\ | | | | | | | | AR: take precision into count when assigning a value to timestamp attribute
| * Fixed taking precision into count when assigning a value to timestamp attributeBogdan Gusiev2015-09-231-11/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Timestamp column can have less precision than ruby timestamp In result in how big a fraction of a second can be stored in the database. m = Model.create! m.created_at.usec == m.reload.created_at.usec # => false # due to different seconds precision in Time.now and database column If the precision is low enough, (mysql default is 0, so it is always low enough by default) the value changes when model is reloaded from the database. This patch fixes that issue ensuring that any timestamp assigned as an attribute is converted to column precision under the attribute.
* | introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-0/+11
|/ | | | | | | | | | | | | | | | | These new methods are used from the Active Record model layer to determine which relations are viable to back a model. These new methods allow us to change `conn.tables` in the future to only return tables and no views. Same for `conn.table_exists?`. The goal is to provide the following introspection methods on the connection: * `tables` * `table_exists?` * `views` * `view_exists?` * `data_sources` (views + tables) * `data_source_exists?` (views + tables)
* Merge pull request #21609 from kamipo/do_not_dump_view_as_tableJeremy Daer2015-09-191-0/+24
|\ | | | | | | Do not dump a view as a table in sqlite3, mysql and mysql2 adapters
| * Add `#views` and `#view_exists?` methods on connection adaptersRyuta Kamizono2015-09-131-0/+24
| |
* | Correctly dump composite primary keyRyuta Kamizono2015-09-201-11/+13
|/ | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end