aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
Commit message (Collapse)AuthorAgeFilesLines
* :nodoc: change_column_null in the implmenting adaptersTony Miller2015-05-031-1/+1
| | | | | | `change_column_null` is doc'ed only in ActiveRecord::ConnectionAdapters::SchemaStatements, so it would make sense to :nodoc: it elsewhere.
* Added documentation for PostGreSQL database_statements [ci skip]Prathamesh Sonpatki2015-04-301-0/+3
| | | | | | - Added documentation for index_name_exists? and rename_index. - Also changed rails to \Rails in documentation of allowed_index_name_length.
* No need to document drop_table in the PostgreSQLAdapterRafael Mendonça França2015-04-061-9/+1
| | | | | | It behaves in the same way that the abstract adapter. [ci skip]
* change the explanation of :if_exists option [ci skip]Mehmet Emin İNAÇ2015-04-061-1/+1
|
* drop_table method documentation for mysql and postgresql adapters [ci skip]Mehmet Emin İNAÇ2015-04-061-0/+8
|
* Make method as nodoc since we are already docummenting at AbstractAdapterRafael Mendonça França2015-03-311-1/+1
|
* PostgreSQL, Fix OID based type casts in C for primitive types.Lars Kanis2015-03-251-3/+3
| | | | | | | | | | The type map was introduced in aafee23, but wasn't properly filled. This mainly adjusts many locations, that expected strings instead of integers or boolean. add_pg_decoders is moved after setup of the StatementPool, because execute_and_clear could potentially make use of it.
* [ci skip] Fix a typo for PostgreSQL text limit, GB instead of Gb.Juanito Fatas2015-03-031-2/+2
|
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-201-6/+0
|
* Handle array option in `type_to_sql`Ryuta Kamizono2015-02-191-19/+16
| | | | | `[]` is a part of `sql_type`, so it is always necessary to respect to array option when `type_to_sql` is called.
* Should handle array option for `:cast_as`Ryuta Kamizono2015-02-191-4/+8
|
* Revert "Allow `:precision` option for time type columns"Sean Griffin2015-02-171-0/+7
| | | | | | | | | | This reverts commit 1502caefd30b137fd1a0865be34c5bbf85ba64c1. The test suite for the mysql adapter broke when this commit was used with MySQL 5.6. Conflicts: activerecord/CHANGELOG.md
* Allow `:precision` option for time type columnsRyuta Kamizono2015-02-121-7/+0
|
* Refactor `quote_default_expression`Ryuta Kamizono2015-02-111-10/+2
| | | | | | | `quote_default_expression` and `quote_default_value` are almost the same handling for do not quote default function of `:uuid` columns. Rename `quote_default_value` to `quote_default_expression`, and remove duplicate code.
* An array type is a part of `sql_type`Ryuta Kamizono2015-02-081-18/+3
| | | | | | `sql_type` is reused in `lookup_cast_type`. If making it a part of `sql_type` when handled array option first, it isn't necessary to do again.
* rm `Column#cast_type`Sean Griffin2015-02-031-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The type from the column is never used, except when being passed to the attributes API. While leaving the type on the column wasn't necessarily a bad thing, I worry that it's existence there implies that it is something which should be used. During the design and implementation process of the attributes API, there have been plenty of cases where getting the "right" type object was hard, but I had easy access to the column objects. For any contributor who isn't intimately familiar with the intents behind the type casting system, grabbing the type from the column might easily seem like the "correct" thing to do. As such, the goal of this change is to express that the column is not something that should be used for type casting. The only places that are "valid" (at the time of this commit) uses of acquiring a type object from the column are fixtures (as the YAML file is going to mirror the database more closely than the AR object), and looking up the type during schema detection to pass to the attributes API Many of the failing tests were removed, as they've been made obsolete over the last year. All of the PG column tests were testing nothing beyond polymorphism. The Mysql2 tests were duplicating the mysql tests, since they now share a column class. The implementation is a little hairy, and slightly verbose, but it felt preferable to going back to 20 constructor options for the columns. If you are git blaming to figure out wtf I was thinking with them, and have a better idea, go for it. Just don't use a type object for this.
* Remove most uses of `Column#cast_type`Sean Griffin2015-01-301-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to remove the type object from the column, and remove columns from the type casting process entirely. The primary motivation for this is clarity. The connection adapter does not have sufficient type information, since the type we want to work with might have been overriden at the class level. By taking this object from the column, it is easy to mistakenly think that the column object which exists on the connection adapter is sufficient. It isn't. A concrete example of this is `serialize`. In 4.2 and earlier, `where` worked in a very inconsistent and confusing manner. If you passed a single value to `where`, it would serialize it before querying, and do the right thing. However, passing it as part of an array, hash, or range would cause it to not work. This is because it would stop using prepared statements, so the type casting would come from arel. Arel would have no choice but to get the column from the connection adapter, which would treat it as any other string column, and query for the wrong value. There are a handful of cases where using the column object to find the cast type is appropriate. These are cases where there is not actually a class involved, such as the migration DSL, or fixtures. For all other cases, the API should be designed as such that the type is provided before we get to the connection adapter. (For an example of this, see the work done to decorate the arel table object with a type caster, or the introduction of `QueryAttribute` to `Relation`). There are times that it is appropriate to use information from the column to change behavior in the connection adapter. These cases are when the primitive used to represent that type before it goes to the database does not sufficiently express what needs to happen. An example of this that affects every adapter is binary vs varchar, where the primitive used for both is a string. In this case it is appropriate to look at the column object to determine which quoting method to use, as this is something schema dependent. An example of something which would not be appropriate is to look at the type and see that it is a datetime, and performing string parsing when given a string instead of a date. This is the type of logic that should live entirely on the type. The value which comes out of the type should be a sufficiently generic primitive that the adapter can be expected to know how to work with it. The one place that is still using the column for type information which should not be necessary is the connection adapter type caster which is sometimes given to the arel table when we can't find the associated table. This will hopefully go away in the near future.
* Add an `:if_exists` option to `drop_table`Stefan Kanev2015-01-191-1/+1
| | | | | | | | | | | If set to `if_exists: true`, it generates a statement like: DROP TABLE IF EXISTS posts This syntax is supported in the popular SQL servers, that is (at least) SQLite, PostgreSQL, MySQL, Oracle and MS SQL Sever. Closes #16366.
* Extract the index length validation to a auxiliar methodRafael Mendonça França2014-12-301-3/+2
|
* Ensures that primary_key method will return nil when multi-pkArthur Neves2014-12-301-4/+4
| | | | | | | When table has a composite primary key, the `primary_key` method for sqlite3 and postgresql was only returning the first field of the key. Ensures that it will return nil instead, as AR dont support composite pks.
* Support for any type primary key.Ryuta Kamizono2014-12-281-9/+0
|
* `force: :cascade` to recreate tables referenced by foreign-keys.Yves Senn2014-12-191-0/+4
|
* Merge pull request #17799 from kamipo/refactor_add_column_optionsRafael Mendonça França2014-11-281-4/+12
|\ | | | | Refactor `add_column_options!`, to move the quoting of default value for :uuid in `quote_value`.
| * Rename to `quote_default_expression` from `quote_value`Ryuta Kamizono2014-11-281-1/+1
| |
| * Refactor `add_column_options!`, to move the quoting of default value for ↵Ryuta Kamizono2014-11-281-4/+12
| | | | | | | | :uuid in `quote_value`.
* | Refactor `SchemaCreation#visit_AddColumn`Ryuta Kamizono2014-11-271-6/+0
|/
* allow types to be passed in for USING castsAaron Patterson2014-11-241-0/+3
| | | | | | | This allows us so abstract the migration from the type that is actually used by Rails. For example, ":string" may be a varchar or something, but the framework does that translation, and the app shouldn't need to know.
* allow the "USING" statement to be specified on change column callsAaron Patterson2014-11-241-1/+3
|
* Rename the primary key index when renaming a table in pgSean Griffin2014-11-221-0/+3
| | | | | | | | Also checked to make sure this does not affect foreign key constraints. (It doesn't). Fixes #12856 Closes #14088
* raise a better exception for renaming long indexesAaron Patterson2014-11-201-0/+3
|
* remove unused and untested APIAaron Patterson2014-10-311-6/+2
|
* fix set_pk_sequence and add a test for it.Aaron Patterson2014-10-311-1/+1
|
* Added region sequencing of primary keys for Postgres.Joe Rafaniello2014-10-311-0/+21
| | | | | | | Skip setting sequence on a table create if the value is 0 since it will start the first value at 1 anyway. This fixes the PG error 'setval: value 0 is out of bounds for sequence vms_id_seq...' encountered when migrating a new DB. BugzID: 15452,9772,13475,16850
* Use #inject over #sum to build PG create DB statementGeoff Harcourt2014-09-171-2/+2
| | | | | | | | | | | | While investigating #16951 I found that another library's monkey-patching of `Enumerable` was causing the test migrations helper to break when trying to build the `CREATE DATABASE` statement. The prior approach used `#sum` to build the string from the options hash. As the code that combines the options to build the database statement is not user-facing, using `#inject` here instead will remove the only place where the database creation/migration code is dependent on ActiveSupport's monkey-patching of `Enumerable`.
* pg, correctly dump foreign keys targeting tables in a different schema.Yves Senn2014-09-171-1/+2
| | | | | | Closes #16907. [Matthew Draper & Yves Senn]
* pg, `default_sequence_name` needs to return a string.Yves Senn2014-08-251-2/+2
| | | | | | | | | This is a reacon to https://github.com/rails/rails/commit/d6c1205584b1ba597db4071b168681678b1e9875#commitcomment-7502487 This backwards incompatibility was introduced with d6c12055 to fix #7516. However both `connection.default_sequence_name` and `model.sequence_name` are public API. The PostgreSQL adapter should honor the interface and return strings. /cc @matthewd @chancancode
* CHANGELOG & improvements to #16649Godfrey Chan2014-08-231-2/+2
| | | | | * Require either FIRST or LAST qualifier for "NULLS ..." * Require whitespace before "NULLS ..."
* Don't trim excess whitespace in pg #columns_for_distinctAgis-2014-08-241-1/+2
| | | | Fixes #16623 introduced by https://github.com/rails/rails/commit/3d5a2019bcccc6fb01bee4811ca669f4383edb51
* pg, `change_column_default, :table, :column, nil` issues `DROP DEFAULT`.Yves Senn2014-07-241-1/+9
| | | | | | | | | | | | Closes #16261. [Matthew Draper, Yves Senn] Using `DEFAULT NULL` results in the same behavior as `DROP DEFAULT`. However, PostgreSQL will cast the default to the columns type, which leaves us with a default like "default NULL::character varying". /cc @matthewd
* Always pass a column with a type object to quoteSean Griffin2014-06-281-0/+8
| | | | | | | | The only case where we got a column that was not `nil`, but did not respond to `cast_type` was when type casting the default value during schema creation. We can look up the cast type, and add that object to the column definition. Will allow us to consistently rely on the type objects for type casting in all directions.
* rename sequence only if it existsAbdelkader Boudih2014-06-271-3/+3
|
* fk: review corrections: indent, visibility, syntax, wording.Yves Senn2014-06-261-12/+12
|
* fk: support for on_updateYves Senn2014-06-261-7/+12
|
* fk: rename `dependent` to `on_delete`Yves Senn2014-06-261-2/+2
|
* fk: support dependent option (:delete, :nullify and :restrict).Yves Senn2014-06-261-1/+8
|
* fk: generalize using `AlterTable` and `SchemaCreation`.Yves Senn2014-06-261-20/+0
|
* fk: `foreign_keys`, `add_foreign_key` and `remove_foreign_key` for MySQLYves Senn2014-06-261-7/+0
|
* fk: add `foreign_keys` for PostgreSQL adapter.Yves Senn2014-06-261-0/+24
|
* fk: `add_foreign_key` and `remove_foreign_key` for PostgreSQL adapter.Yves Senn2014-06-261-0/+27
|
* pg, support default values for enum types. Closes #7814.Yves Senn2014-05-301-1/+1
| | | | | This is an intermediate solution. It is related to the refactoring @sgrif is making and will change in the future.