aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* SQLite 2 support has been dropped [ci skip]Ryuta Kamizono2016-02-041-1/+0
|
* Extract `ExplainPrettyPrinter` to appropriate filesRyuta Kamizono2016-02-011-15/+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}`.
* Remove `delete_sql` in sqlite3 adapterRyuta Kamizono2016-01-071-5/+0
| | | | | `sql += " WHERE 1=1"` was introduced in 69cb942. But it is not needed. ref https://www.sqlite.org/lang_delete.html
* Refactor `connection.insert_sql`Ryuta Kamizono2016-01-071-5/+0
| | | | `connection.insert_sql` is almost the same as `connection.insert`.
* Fix `connection#create` in PG adapterRyuta Kamizono2016-01-051-1/+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.
* Support supports_datetime_with_precision? for sqlite3Yasuo Honda2015-11-301-0/+4
|
* Refactor `AbstractAdapter#initialize`Ryuta Kamizono2015-11-301-2/+1
| | | | `pool` in args is unused anymore. And `config` is used in all adapters.
* Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-2/+26
| | | | | | | | | | 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?`.
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-2/+2
|
* Remove `#tables` extra args againRyuta Kamizono2015-10-221-12/+8
| | | | | | This issue was resolved by #21687 already. But re-add args by #18856. `#tables` extra args was only using by `#table_exists?`. This is for internal API. This commit will remove these extra args again.
* Do not cache prepared statements that are unlikely to have cache hitsSean Griffin2015-10-201-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Wrong usage of 'a' in docs fixed [ci skip]Mehmet Emin İNAÇ2015-10-031-1/+1
|
* introduce `conn.data_source_exists?` and `conn.data_sources`.Yves Senn2015-09-221-0/+2
| | | | | | | | | | | | | | | | | 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/+13
|\ | | | | | | 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/+13
| |
* | Merge pull request #21614 from kamipo/correctly_dump_composite_primary_keyJeremy Daer (Kemper)2015-09-191-3/+2
|\ \ | | | | | | Correctly dump composite primary key
| * | Correctly dump composite primary keyRyuta Kamizono2015-09-201-3/+2
| |/ | | | | | | | | | | | | | | | | Example: create_table :barcodes, primary_key: ["region", "code"] do |t| t.string :region t.integer :code end
* / Remove `@connection` in `StatementPool`Ryuta Kamizono2015-09-201-2/+1
|/ | | | | `@connection` in `StatementPool` is only used for PG adapter. No need for abstract `StatementPool` class.
* Support dropping indexes concurrently in PostgresGrey Baker2015-09-051-1/+2
| | | | | See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html for more details.
* Ensure that microsecond precision is only used for version of mysql that ↵Jori Hardman2015-07-201-12/+0
| | | | support it. Fixes #19711
* Add reversible syntax for change_column_defaultPrem Sichanugrist2015-06-261-1/+3
| | | | | | | | | | | | | Passing `:from` and `:to` to `change_column_default` makes this command reversible as user has defined its previous state. So, instead of having the migration command as: change_column_default(:posts, :state, "draft") They can write it as: change_column_default(:posts, :state, from: nil, to: "draft")
* Add collation support for string and text columns in SQLite3Akshay Vishnoi2015-05-281-4/+51
|
* Remove `require 'arel/visitors/bind_visitor'`Ryuta Kamizono2015-05-191-1/+0
| | | | | This line introduced by the commit fd398475 for using `Arel::Visitors::BindVisitor`. Currently it is not used.
* Eliminate the duplication code of `StatementPool`Ryuta Kamizono2015-05-191-28/+1
|
* :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.
* cache quoted column names in SQLite3Aaron Patterson2015-02-241-1/+2
| | | | we do this in other adapters, and it's a nice speed improvement
* Remove the SQLite3 Binary subclassSean Griffin2015-02-111-18/+0
| | | | | | As far as I can tell, the original reason that this behavior was added has been sufficiently resolved elsewhere, as we no longer remove the encoding of strings coming out of the database.
* Allow a symbol to be passed to `attribute`, in place of a type objectSean Griffin2015-02-061-0/+4
| | | | | | | | | | | | | | | | | | The same is not true of `define_attribute`, which is meant to be the low level no-magic API that sits underneath. The differences between the two APIs are: - `attribute` - Lazy (the attribute will be defined after the schema has loaded) - Allows either a type object or a symbol - `define_attribute` - Runs immediately (might get trampled by schema loading) - Requires a type object This was the last blocker in terms of public interface requirements originally discussed for this feature back in May. All the implementation blockers have been cleared, so this feature is probably ready for release (pending one more look-over by me).
* rm `Column#cast_type`Sean Griffin2015-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Always convert strings to UTF-8, regardless of column type in SQLiteSean Griffin2015-01-281-11/+6
| | | | | | | | All columns which would map to a string primitive need this behavior. Binary has it's own marker type, so it won't go through this conversion. String and text, which need this, will. Fixes #18585.
* Remove Relation#bind_paramsSean Griffin2015-01-271-5/+3
| | | | | | | | `bound_attributes` is now used universally across the board, removing the need for the conversion layer. These changes are mostly mechanical, with the exception of the log subscriber. Additional, we had to implement `hash` on the attribute objects, so they could be used as a key for query caching.
* Errors raised in `type_cast_for_database` no longer raise on assignmentSean Griffin2015-01-231-1/+1
| | | | Fixes #18580.
* Merge pull request #17820 from fw42/restore_query_cache_on_rollbackRafael Mendonça França2015-01-021-1/+1
|\ | | | | | | Clear query cache on rollback
| * Restore query cache on rollbackFlorian Weingarten2014-12-011-1/+1
| |
* | Don't load an entire table into memory to copy it on SQLiteSean Griffin2015-01-011-15/+4
| | | | | | | | SQL has mechanisms we can use to copy data from one table into another.
* | Ensures that primary_key method will return nil when multi-pkArthur Neves2014-12-301-4/+3
| | | | | | | | | | | | | | 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.
* | Refactor `quoted_date`Ryuta Kamizono2014-12-111-10/+0
| | | | | | | | Move microseconds formatting to `AbstractAdapter`.
* | Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-5/+5
|/
* Mark comments that should not be in the docsclaudiob2014-11-241-0/+2
| | | | | | | | | | | Some comments that are meant to separate blocks of code in a file show up on http://api.rubyonrails.org as though they were part of the documentation. This commit hides those comments from the documentation. Stems from the discussion with @zzak at https://github.com/voloko/sdoc/issues/79#issuecomment-64158738 [ci skip]
* tiny code improvement in sqlite3 adapter:Andrey Deryabin2014-11-101-6/+2
| | | | | - remove unused method `supports_add_column?` - change additional restriction method to `valid_alter_table_type?` - fix code style
* Avoid unnecessary allocations/callsPablo Herrero2014-11-021-1/+1
|
* Remove duplicate 'select' database statementclaudiob2014-10-201-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `select` method has the same definition in almost all database adapters, so it can be moved from the database-specific adapters (PostgreSQl, MySQL, SQLite) to the abstract `database_statement`: ```ruby def select(sql, name = nil, binds = []) exec_query(sql, name, binds) end ``` --- More details about this commit: the only two DB-specific adapters that have a different definition of `select` are MySQLAdapter and MySQL2Adapter. In MySQLAdapter, `select` invokes `exec_query(sql, name, binds)`, so calling `super` achieves the same goal with less repetition. In MySQL2Adapter, `select` invokes `exec_query(sql, name)`, that is, it does not pass the `binds` parameter like other methods do. However, [MySQL2Adapter's `exec_query`](https://github.com/rails/rails/blob/74a527cc63ef56f3d0a42cf638299958dc7cb08c/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb#L228L231) works exactly the same whether this parameters is passed or not, so the output does not change: ```ruby def exec_query(sql, name = 'SQL', binds = []) result = execute(sql, name) ActiveRecord::Result.new(result.fields, result.to_a) end ```
* Merge pull request #14056 from girishso/14041Yves Senn2014-09-091-1/+1
|\ | | | | | | | | | | | | SQLite3Adapter now checks for views in table_exists? fixes: 14041 Conflicts: activerecord/CHANGELOG.md
| * SQLite3Adapter now checks for views in table_exists? fixes: 14041Girish S2014-02-141-1/+1
| |
* | introduce `connection.supports_views?` and basic view tests.Yves Senn2014-09-091-0/+4
| | | | | | | | | | | | | | `AbstractAdapter#supports_views?` defaults to `false` so we have to turn it on in adapter subclasses. Currently the flag only controls test execution. /cc @yahonda
* | Freeze ADAPTER_NAME in adaptersAbdelkader Boudih2014-09-051-4/+1
| |
* | Fix documentation of SQlite3Adapter.columnsa3gis2014-07-251-1/+1
| | | | | | As of https://github.com/rails/rails/commit/e781aa31fc52a7c696115302ef4d4e02bfd1533b SQLite3Column has been dropped.
* | Merge pull request #16055 from sgrif/sg-refactor-sqlite3-stringsMatthew Draper2014-07-121-14/+22
|\ \ | | | | | | Use a type object for type casting behavior on SQLite3
| * | Use a type object for type casting behavior on SQLite3Sean Griffin2014-07-111-14/+22
| | |