aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-3/+1
|
* Mark comments that should not be in the docsclaudiob2014-11-241-0/+4
| | | | | | | | | | | 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]
* Wrap code snippets in +, not backticks, in sdocclaudiob2014-11-201-1/+1
| | | | | | | | I grepped the source code for code snippets wrapped in backticks in the comments and replaced the backticks with plus signs so they are correctly displayed in the Rails documentation. [ci skip]
* Avoid unnecessary allocations/callsPablo Herrero2014-11-021-1/+1
|
* Remove duplicate 'select' database statementclaudiob2014-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* Freeze ADAPTER_NAME in adaptersAbdelkader Boudih2014-09-051-1/+1
|
* Fix version detection for RENAME INDEX support. Fixes #15931.Jeff Browning2014-07-151-3/+3
|
* add missing `:nodoc:` for recent refactorings. [ci skip]Yves Senn2014-06-241-2/+2
| | | | | | | | | | Adding `# :nodoc:` to the parent `class` / `module` is not going to ignore nested classes or modules. There is a modifier `# :nodoc: all` but sadly the containing class or module will continue to be in the docs. /cc @sgrif
* /mysql/i -> MySQL, Spell correct in continuation to #15555Akshay Vishnoi2014-06-141-1/+1
|
* Move types to the top level `ActiveRecord` namespaceSean Griffin2014-05-271-1/+1
| | | | | `ActiveRecord::ConnectionAdapters::Type::Value` => `ActiveRecord::Type::Value`
* Add missing nodocs to MySQL adapterSean Griffin2014-05-211-3/+3
|
* Use the generic type map object for mysql field lookupsSean Griffin2014-05-201-23/+9
|
* Merge pull request #15203 from sgrif/sg-delegate-type-castRafael Mendonça França2014-05-201-20/+0
|\ | | | | Replace `type_cast` case statement with delegation
| * Replace `type_cast` case statement with delegationSean Griffin2014-05-201-20/+0
| | | | | | | | | | | | | | | | All subclasses of column were now delegating `type_cast` to their injected type object. We can remove the overriding methods, and generalize it on the `Column` class itself. This also enabled us to remove several column classes completely, as they no longer had any meaningful behavior of their own.
* | Use general types for mysql fieldsSean Griffin2014-05-201-69/+11
|/
* Delegate type_cast to injected type object in mysqlSean Griffin2014-05-201-38/+40
|
* Delegate `Column#type` to the injected type objectSean Griffin2014-05-191-0/+1
| | | | | | | | | | | | | | | | The decision to wrap type registrations in a proc was made for two reasons. 1. Some cases need to make an additional decision based on the type (e.g. a `Decimal` with a 0 scale) 2. Aliased types are automatically updated if they type they point to is updated later. If a user or another adapter decides to change the object used for `decimal` columns, `numeric`, and `number` will automatically point to the new type, without having to track what types are aliased explicitly. Everything else here should be pretty straightforward. PostgreSQL ranges had to change slightly, since the `simplified_type` method is gone.
* Add a type object to Column constructorSean Griffin2014-05-171-2/+3
| | | | | | Part of #15134. In order to perform typecasting polymorphically, we need to add another argument to the constructor. The order was chosen to match the `oid_type` on `PostgreSQLColumn`.
* Clarify 'database does not exist' message and implementation.Jeremy Kemper2014-04-011-2/+2
| | | | | | | | | | | * Clarify what the situation is and what to do. * Advise loading schema using `rake db:setup` instead of migrating. * Use a rescue in the initializer rather than extending the error message in-place. * Preserve the original backtrace of other errors by using `raise` rather than raising again with `raise error`. References 0ec45cd15d0a2f5aebc75e23d841b6c12f3ba763
* Fix regression on `.select_*` methods.Arthur Neves2014-01-301-2/+2
| | | | | | | | | | | | | | | | | | This was a common pattern: ``` query = author.posts.select(:title) connection.select_one(query) ``` However `.select` returns a ActiveRecord::AssociationRelation, which has the bind information, so we can use that to get the right sql query. Also fix select_rows on postgress and sqlite3 that were not using the binds [fixes #7538] [fixes #12017] [related #13731] [related #12056]
* Raise NoDatabaseError when db does not existschneems2013-12-241-0/+6
| | | Building on the work of #13427 this PR adds a helpful error message to the adapters: mysql, mysql2, and sqlite3
* Fix mysql to support duplicated column namesKassio Borges2013-12-131-3/+8
| | | | | | | | | | This will fix the [broken test](https://github.com/rails/rails/commit/4a2650836680f51490e999c3c8441a2f9adff96e) `test_with_limiting_with_custom_select`. The query's result was built in a hash with column name as key, if the result have a duplicated column name the last value was overriding the first one.
* Merge pull request #12779 from ↵Aaron Patterson2013-11-151-2/+0
|\ | | | | | | | | dougbarth/dont_swallow_exceptions_during_transactional_statements_in_mysql Don't swallow exceptions in transctional statements
| * Don't swallow exceptions in transctional statementsDoug Barth2013-11-051-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MySQL connection adapater swallows all StandardError exceptions, which includes Mysql::Error and Mysql2::Error. The comment in the exception clause claims errors thrown here indicate that transactions aren't supported by the server but that isn't necessarily true. It's possible the MySQL server has gone away and swallowing a failed commit may let the application return a successful response when the data has not been saved. Also, replication libraries like Galera require that the application handle exceptions thrown at BEGIN/COMMIT. I'm unable to determine what version of MySQL threw an exception for transactional statements. I tried as far back as 3.23.49 with InnoDB disabled but BEGIN & COMMIT statements do not throw an error. If there's a real case for this logic to continue, we could instead push this behavior into a configuration setting. The exception swallowing has been there since the beginning: db045dbbf60b53dbe013ef25554fd013baf88134
* | Unifies mysql and mysql2 casting of booleans.Yves Senn2013-11-111-6/+0
| |
* | Don't use Active Support where we don't need toRafael Mendonça França2013-11-091-1/+1
| |
* | log bind variables after they were type casted.Yves Senn2013-11-091-2/+6
|/ | | | | | | | | | | | | | | The log output used to be confusing in situation where type casting has "unexpected" effects. For example when finding records with a `String`. BEFORE: irb(main):002:0> Event.find("im-no-integer") D, [2013-11-09T11:10:28.998857 #1706] DEBUG -- : Event Load (4.5ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", "im-no-integer"]] AFTER: irb(main):002:0> Event.find("im-no-integer") D, [2013-11-09T11:10:28.998857 #1706] DEBUG -- : Event Load (4.5ms) SELECT "events".* FROM "events" WHERE "events"."id" = $1 LIMIT 1 [["id", 0]]
* fix code typo in `MysqlAdapter` .Closes #12647.Yves Senn2013-10-301-1/+1
|
* Remove invalid commentRafael Mendonça França2013-09-111-4/+0
| | | | This is not valid anymore after 08477a651648ba4417ded128aa37b9ae0dcbc9ce
* Check if the SQL is not a prepared statementRafael Mendonça França2013-09-111-1/+1
| | | | | | | | | When the adapter is with prepared statement disabled and the binds array is not empty the connection adapter will try to set the binds values and will fail. Now we are checking if the adapter has the prepared statement disabled. Fixes #12023
* chmod -xAkira Matsuda2013-08-121-0/+0
|
* Set field encoding to client_encoding for mysql adapter.Koichi Sasada2013-08-081-0/+8
|
* Free result_metadata directly instead of freeing 2nd, redundant call.Peter Kovacs2013-08-051-1/+1
| | | `result_metadata` returns a new object each time it is called, so calling `result_metadata.free` is essentially a noop. Instead call `free` directly on the metadata when we're done with it.
* Revert "Merge pull request #11120 from awilliams/ar_mysql2_boolean_quoting"Yves Senn2013-07-171-0/+6
| | | | | This reverts commit cb1d07e43926bcec95cb8b4a663ca9889173395a, reversing changes made to 754a373e301d2df0b12a11083405252722bc8366.
* Unifies mysql and mysql2 casting of booleansawilliams2013-07-161-6/+0
| | | | | Using the mysql2 adapter, boolean values were sometimes being incorrectly cast to 't' or 'f'. This changes the cast to match the mysql adapter behavior, ie 1 and 0.
* tiny types should only be integers when the length is <= 1. fixes #10620Aaron Patterson2013-05-151-3/+9
|
* fix typosVipul A M2013-04-211-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-03-301-2/+2
|\ | | | | | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/adapter_test.rb guides/source/testing.md [ci skip]
| * nodoc AR::ConnectionHandling for adapters [ci skip]Francesco Rodriguez2013-03-151-2/+2
| |
* | respect auto_increment in rename_column for mysqlVipul A M2013-03-271-2/+2
|/
* Do not type cast all the database url values.Rafael Mendonça França2013-02-241-1/+1
| | | | | | We should only type cast when we need to use. Related to 4b005fb371c2e7af80df7da63be94509b1db038c
* Session variables for mysql, mysql2, and postgresql adapters can be setAaron Stone2012-12-081-12/+5
| | | | | | | | | in the new 'variables:' hash in each database config section in database.yml. The key-value pairs of this hash will be sent in a 'SET key = value, ...' query on new database connections. The configure_connection methods from mysql and mysql2 into are consolidated into the abstract_mysql base class.
* Be a bit less conservative with mysql in adapterCarlos Antonio da Silva2012-11-191-1/+1
|
* Bump mysql gem version to the newly 2.9.0, fix build.Carlos Antonio da Silva2012-11-171-1/+1
|
* The default value of a text/blob in mysql strict mode should be nilJon Leighton2012-10-191-4/+2
| | | | | | | | | In non-strict mode it is '', but if someone is in strict mode then we should honour the strict semantics. Also, this removes the need for a completely horrible hack in dirty.rb. Closes #7780
* Ensure disconnecting or reconnecting resets the transaction stateJon Leighton2012-09-151-1/+2
|
* Remove expired comment. This method is used from other place.kennyj2012-09-111-2/+0
|
* Refactor AR::Result or inherits. Because we have redundant codes aboutkennyj2012-08-221-8/+1
|
* teaching the mysql adapter how to typecast strings returned from the databaseAaron Patterson2012-07-131-2/+132
|