aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-8/+8
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* Use tt in doc for ActiveRecord [ci skip]Yoshiyuki Hirano2017-08-271-2/+2
|
* Refactor `SchemaDumper` to make it possible to adapter specific customizationRyuta Kamizono2017-08-221-1/+0
| | | | | | | Currently `SchemaDumper` is only customizable for column options. But 3rd party connection adapters (oracle-enhanced etc) need to customizable for table or index dumping also. To make it possible, I introduced adapter specific `SchemaDumper` classes for that.
* Update links to use https instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* Place `update_table_definition` consistently in `SchemaStatements`Ryuta Kamizono2017-08-211-4/+0
|
* Restore `to_sql` to return only SQL (#29945)Ryuta Kamizono2017-08-181-2/+1
| | | | Because `to_sql` is public API. I introduced `to_sql_and_binds` internal API to return SQL and binds.
* Refactor Active Record to let Arel manage bind paramsSean Griffin2017-07-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common source of bugs and code bloat within Active Record has been the need for us to maintain the list of bind values separately from the AST they're associated with. This makes any sort of AST manipulation incredibly difficult, as any time we want to potentially insert or remove an AST node, we need to traverse the entire tree to find where the associated bind parameters are. With this change, the bind parameters now live on the AST directly. Active Record does not need to know or care about them until the final AST traversal for SQL construction. Rather than returning just the SQL, the Arel collector will now return both the SQL and the bind parameters. At this point the connection adapter will have all the values that it had before. A bit of this code is janky and something I'd like to refactor later. In particular, I don't like how we're handling associations in the predicate builder, the special casing of `StatementCache::Substitute` in `QueryAttribute`, or generally how we're handling bind value replacement in the statement cache when prepared statements are disabled. This also mostly reverts #26378, as it moved all the code into a location that I wanted to delete. /cc @metaskills @yahonda, this change will affect the adapters Fixes #29766. Fixes #29804. Fixes #26541. Close #28539. Close #24769. Close #26468. Close #26202. There are probably other issues/PRs that can be closed because of this commit, but that's all I could find on the first few pages.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Set `represent_boolean_as_integer` via `configuration`yuuji.yaginuma2017-07-161-1/+1
|
* Fix boolean column migration scriptyuuji.yaginuma2017-07-131-1/+1
|
* Change sqlite3 boolean serialization to use 1 and 0Lisa Ugray2017-07-111-0/+18
| | | | | | | | | | | | | | | | | | | | Abstract boolean serialization has been using 't' and 'f', with MySQL overriding that to use 1 and 0. This has the advantage that SQLite natively recognizes 1 and 0 as true and false, but does not natively recognize 't' and 'f'. This change in serialization requires a migration of stored boolean data for SQLite databases, so it's implemented behind a configuration flag whose default false value is deprecated. The flag itself can be deprecated in a future version of Rails. While loaded models will give the correct result for boolean columns without migrating old data, where() clauses will interact incorrectly with old data. While working in this area, also change the abstract adapter to use `"TRUE"` and `"FALSE"` as quoted values and `true` and `false` for unquoted. These are supported by PostreSQL, and MySQL remains overriden.
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-3/+3
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Don't cache queries for schema statementsRyuta Kamizono2017-06-301-3/+3
| |/ | | | | | | | | | | `test_middleware_caches` is sometimes failed since #29454. The failure is due to schema statements are affected by query caching. Bypassing query caching for schema statements to avoid the issue.
* / [Active Record] require => require_relativeAkira Matsuda2017-07-011-8/+8
|/
* Use bulk INSERT to insert fixturesKir Shatrov2017-06-201-0/+6
| | | | | | | | Improves the performance from O(n) to O(1). Previously it would require 50 queries to insert 50 fixtures. Now it takes only one query. Disabled on sqlite which doesn't support multiple inserts.
* Deprecate `supports_statement_cache?`Ryuta Kamizono2017-05-011-6/+0
| | | | | | | | | | | | | | `supports_statement_cache?` was introduced in 3.1.0.beta1 (104d0b2) for bind parameter substitution, but it is no longer used in 3.1.0.rc1 (73ff679). Originally it should respect `prepared_statements` rather than `supports_statement_cache?` (fd39847). One more thing, named `supports_statement_cache?` is pretty misreading. We have `StatementCache` and `StatementPool`. However, `supports_statement_cache?` doesn't mean `StatementCache`, but `StatementPool` unlike its name. https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/statement_cache.rb https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/statement_pool.rb
* Refactor `indexes` things in connection adaptersRyuta Kamizono2017-04-161-31/+0
| | | | | | | * Use keyword arguments in `IndexDefinition` to ease to ignore unused options and to avoid to initialize incorrect empty value. * Place it in `SchemaStatements` for consistency. * And tiny tweaks.
* Make internal methods to privateRyuta Kamizono2017-03-271-34/+2
|
* Merge pull request #28068 from kamipo/refactor_data_sourcesRafael França2017-03-131-40/+3
|\ | | | | Extract `data_source_sql` to refactor data source statements
| * Extract `data_source_sql` to refactor data source statementsRyuta Kamizono2017-02-201-40/+3
| |
* | `valid_type?` should accept only supported typesRyuta Kamizono2017-02-281-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `valid_type?` is used in schema dumper to determine if a type is supported. So if `valid_type?(:foobar)` is true, it means that schema dumper is allowed to create `t.foobar`. But it doesn't work. I think that `valid_type?` should accept only supported types. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/schema_dumper.rb#L135-L142 ```ruby columns.each do |column| raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type) next if column.name == pk type, colspec = @connection.column_spec(column) tbl.print " t.#{type} #{column.name.inspect}" tbl.print ", #{format_colspec(colspec)}" if colspec.present? tbl.puts end ```
* | Deprecate `supports_migrations?` on connection adaptersRyuta Kamizono2017-02-271-5/+0
| | | | | | | | | | | | | | `supports_migrations?` was added at 4160b518 to determine if schema statements (`create_table`, `drop_table`, etc) are implemented in the adapter. But all tested databases has been supported migrations since a4fc93c3 at least.
* | Merge pull request #28176 from kamipo/push_valid_type_up_to_abstract_adapterAndrew White2017-02-261-1/+1
|\ \ | | | | | | Push `valid_type?` up to abstract adapter
| * | Push `valid_type?` up to abstract adapterRyuta Kamizono2017-02-261-1/+1
| |/ | | | | | | | | | | | | `valid_type?` should return true if a type exists in `native_database_types` at least. https://github.com/rails/rails/blob/v5.1.0.beta1/activerecord/lib/active_record/schema_dumper.rb#L136
* / Fix `change_column` to drop default with `null: false`Ryuta Kamizono2017-02-261-2/+1
|/ | | | | | | | | | | | | | | | Currently `change_column` cannot drop default if `null: false` is specified at the same time. This change fixes the issue. ```ruby # cannot drop default change_column "tests", "contributor", :boolean, default: nil, null: false # we need the following workaround currently change_column "tests", "contributor", :boolean, null: false change_column "tests", "contributor", :boolean, default: nil ``` Closes #26582
* Deprecate `supports_primary_key?`Ryuta Kamizono2017-02-121-4/+0
| | | | | | | | | | | | `supports_primary_key?` was added to determine if `primary_key` is implemented in the adapter in f060221. But we already use `primary_key` without `supports_primary_key?` (207f266, 5f3cf42) and using `supports_primary_key?` has been removed in #1318. This means that `supports_primary_key?` is no longer used in the internal and Active Record doesn't work without `primary_key` is implemented (all adapters must implement `primary_key`). Closes #27977
* `primary_key` and `references` columns should be identical typeRyuta Kamizono2017-02-071-0/+5
| | | | | | | | Follow up to #26266. The default type of `primary_key` and `references` were changed to `bigint` since #26266. But legacy migration and sqlite3 adapter should keep its previous behavior.
* SQLite: Foreign Key SupportRyuta Kamizono2017-01-171-0/+25
| | | | https://www.sqlite.org/foreignkeys.html
* Translate Foreign Key violation to the specific exception for SQLite3 adapterRyuta Kamizono2017-01-161-0/+21
| | | | | | Raise `ActiveRecord::InvalidForeignKey` when a record cannot be inserted or updated because it references a non-existent record for SQLite3 adapter.
* Deprecate passing `name` to `indexes` like `tables`Ryuta Kamizono2017-01-041-0/+6
| | | | | Passing `name` to `tables` is already deprecated at #21601. Passing `name` to `indexes` is also unused.
* `#tables` and `#table_exists?` and returns only tables and not viewsRafael Mendonça França2016-12-291-20/+13
|
* Remove deprecated `name` argument from `#tables`Rafael Mendonça França2016-12-291-7/+1
|
* Fix Rubocop violations and fix documentation visibilityRafael Mendonça França2016-12-281-2/+2
| | | | | | Some methods were added to public API in 5b14129d8d4ad302b4e11df6bd5c7891b75f393c and they should be not part of the public API.
* Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-10/+9
|
* Translate NOT NULL violation to the specific exceptionRyuta Kamizono2016-12-061-0/+2
| | | | | Raise `ActiveRecord::NotNullViolation` when a record cannot be inserted or updated because it would violate a not null constraint.
* Change MySQL and Postgresql to use Bigint primary keysJon McCartie2016-12-051-0/+2
|
* Make `:auto_increment` to internal primary key optionRyuta Kamizono2016-12-061-0/+9
| | | | | | Using `:auto_increment` option for abstracting the DB-specific auto incremental types. It is worth to ease to implement the compatibility layer.
* Add `:nodoc` to `table_structure`Ryuta Kamizono2016-11-121-9/+2
| | | | | | | | Follow up to #27008. `table_structure` is an internal method so it is better to hide it in the doc. And alias `table_structure` to `column_definitions` to remove the duplicated `columns` method in the sqlite3 adapter.
* Refactor column initialization into `new_column_from_field`Kir Shatrov2016-11-111-12/+16
| | | | that accepts results of SHOW FIELDS
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-6/+6
|
* Fix the variable scoping issue I introduced in ↵Matthew Draper2016-10-281-2/+2
| | | | 007e50d8e5a900547471b6c4ec79d9d217682c5d
* Permit loads while queries are runningMatthew Draper2016-10-271-19/+25
| | | | | A query may wait on a database-level lock, which could lead to a deadlock between threads.
* Quote table name properlyRyuta Kamizono2016-10-141-4/+6
| | | | If does not quote table name properly, invalid SQL is generated.
* Add three new rubocop rulesRafael Mendonça França2016-08-161-5/+5
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-40/+40
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.