Commit Graph

99 Commits

Author SHA1 Message Date
Sean Griffin
8b07f18599 Stop explicitly passing nil as the column to type_cast
So we can change the arity later.
2015-01-01 11:24:29 -07:00
Sean Griffin
19537ecd0f Stop relying on columns in sqlite quoting tests
The string encoding test wasn't using the types for anything. The
boolean casting test included logic that should be in the tests for the
types, and the string test was legitimately not testing anything useful.
2015-01-01 10:00:08 -07:00
Arthur Neves
5acd24bbea
Ensures that primary_key method will return nil when multi-pk
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.
2014-12-30 12:36:37 -05:00
Sean Griffin
b98668decb Go through normal where logic when preloading associations
This will allow eager type casting to take place as needed. There
doesn't seem to be any particular reason that the `in` statement was
forced for single values, and the commit message where it was introduced
gives no context.

See
d90b4e2615
2014-12-26 16:12:56 -07:00
Erik Michaels-Ober
d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
Sean Griffin
eb26f24bde Remove the unused second argument to substitute_at
Oh hey, we got to remove some code because of that!
2014-11-17 15:04:40 -08:00
Sean Griffin
c01b20b658 rm reorder_bind_params
Arel handles this for us automatically. Updated tests, as BindParam is
no longer a subclass of SqlLiteral. We should remove the second argument
to substitute_at entirely, as it's no longer used
2014-11-17 14:57:01 -08:00
Arun Agrawal
9ae210ba09 Build fix when running in isolation
`Computer` class needs to be require

See #17217 for more details
2014-11-14 10:24:11 +01:00
Yves Senn
d2069d60ae Merge pull request #14056 from girishso/14041
SQLite3Adapter now checks for views in table_exists? fixes: 14041

Conflicts:
	activerecord/CHANGELOG.md
2014-09-09 11:35:17 +02:00
Matthew Draper
dc4945dde9 Merge pull request #16055 from sgrif/sg-refactor-sqlite3-strings
Use a type object for type casting behavior on SQLite3
2014-07-12 01:16:08 +09:30
Sean Griffin
d739dd1627 Use a type object for type casting behavior on SQLite3 2014-07-11 07:29:12 -06:00
Zachary Scott
2f716694f2 Change back occurrences of SQLite(3) to sqlite3 when referring to the
adapter, fixed from #16057 [ci skip]
2014-07-06 11:47:16 -07:00
Akshay Vishnoi
ddad32978d [ci skip] /sqlite/i --> SQLite 2014-07-06 15:23:12 +05:30
Sean Griffin
b404613c97 Always pass a column with a type object to quote
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.
2014-06-28 14:50:30 -06:00
Sean Griffin
4d3e88fc75 Don't type cast the default on the column
If we want to have type decorators mess with the attribute, but not the
column, we need to stop type casting on the column. Where possible, we
changed the tests to test the value of `column_defaults`, which is
public API. `Column#default` is not.
2014-06-17 16:02:53 -06:00
Akshay Vishnoi
5c22db25aa Test Case - Change method name 2014-05-28 01:46:19 +05:30
Sean Griffin
597d9c8af8 Remove checks against column.type in abstract adapter quoting
The intention is to eventually remove `column` from the arguments list
both for `quote` and for `type_cast` entirely. This is the first step
to that end.
2014-05-26 09:04:17 -07:00
Sean Griffin
05dd3df35d Remove Column#primary
It appears to have been used at some point in the past, but is no longer
used in any meaningful way. Whether a column is considered primary is
a property of the model, not the schema/column. This also removes the
need for yet another layer of caching of the model's schema, and we can
leave that to the schema cache.
2014-05-23 11:09:48 -07:00
Sean Griffin
0b682e4b05 Delegate Column#type to the injected type object
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.
2014-05-19 08:07:21 -07:00
Sean Griffin
4bd5dffc85 Add a type object to Column constructor
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`.
2014-05-17 17:16:05 -06:00
Akshay Vishnoi
91d7b6fc11 Test typecasting on instance rather than class itself 2014-05-03 09:17:36 +05:30
Rafael Mendonça França
372e28ce22 Merge pull request #13640 from maginatics/fix_sqlite3_ensure_master
SQLite3: Always close statements.

Conflicts:
	activerecord/CHANGELOG.md
2014-05-01 14:10:04 -03:00
Aaron Patterson
3321d1a2d1 working against arel/collector branch 2014-04-09 10:56:42 -07:00
Aaron Patterson
347d74a03b Merge branch 'master' into adequaterecord
* master: (122 commits)
  Rails.application should be set inside before_configuration hook
  remove check for present? from delete_all
  Remove useless begin..end
  Build the reverse_order on its proper method.
  Use connection-specific bytea escaping
  Ignore order when doing count.
  make enums distinct per class
  Remove unused `subclass_controller_with_flash_type_bar` var from flash test.
  fix CollectionProxy delete_all documentation
  Added OS X specific commands to installation guide [ci skip] Recommended using homebrew for installing MySQL and PostgreSQL
  Fix setup of adding _flash_types test.
  Use SVG version of travis build status badge [skip ci]
  W3C CSP document moved to gihub.io URL [ci skip]
  sprockets-rails was released
  Fix the test defining the models in the right place
  Add CHANGELOG entry for #11650 [ci skip]
  Declare the assets dependency
  Use sass-rails 4.0.3
  Make possible to use sprockets-rails 2.1
  add missing parentheses to validates_with documentation [skip ci]
  ...
2014-04-07 15:26:13 -07:00
Matthew Draper
f846828dae Revise 'sqlite3:' URL handling for smoother upgrades
Restore the 4.0 behaviour for 'sqlite3:///', but deprecate it. We'll
change to the absolute-path interpretation in 4.2.

The current "correct" spellings for in-memory, relative, and absolute
URLs, respectively, are:

    sqlite3::memory:
    sqlite3:relative/path
    sqlite3:/full/path

Substantially reverses/defers fbb79b517f3127ba620fedd01849f9628b78d6ce.
Uncovered by @guilleiguaran while investigating #14495, though that
sounds like a different issue.
2014-04-03 01:30:27 +10:30
Guo Xiang Tan
0264762fea Refactor test to use DdlHelper.
Follow-Up to https://github.com/rails/rails/pull/14400

This ensures that all tables are removed after each test and thereby
allowing us to run the tests in a random order.
2014-03-29 09:43:19 -07:00
Guo Xiang Tan
0212a41700 Fix tests not unsubscribing from Notifications.
See https://github.com/rails/rails/blob/master/activesupport/lib/active_support/notifications.rb#L131
2014-03-28 18:56:40 -07:00
Aaron Patterson
23ce2f61b5 Merge branch 'master' into adequaterecord
* master:
  Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"
  No need to use symbols
  Don't skip tests if they are not broken. Just don't define they
  Fix typo [ci skip]
  Resolve encoding issues with arrays of hstore (bug 11135).
  Fix coffeescript sample [ci skip]
2014-02-17 13:42:42 -08:00
Aaron Patterson
fe42effb11 Merge branch 'master' into adequaterecord
* master: (311 commits)
  Add a missing changelog entry for #13981 and #14035
  Revert "Fixed plugin_generator test"
  implements new option :month_format_string for date select helpers [Closes #13618]
  add factory methods for empty alias trackers
  guarantee a list in the alias tracker so we can remove a conditional
  stop exposing table_joins
  make most parameters to the AliasTracker required
  make a singleton for AssociationScope
  pass the association and connection to the scope method
  pass the tracker down the stack and construct it in the scope method
  clean up add_constraints signature
  remove the reflection delegate
  remove klass delegator
  remove railties changes. fixes #14054
  remove chain delegate
  remove scope_chain delegate
  Add verb to sanitization note
  fix path shown in mailer's templates
  updated Travis build status image url
  fix guide active_support_core_extensions. add Note to String#indent [ci skip]
  ...

Conflicts:
	activerecord/lib/active_record/associations/join_dependency.rb
	activerecord/test/cases/associations/association_scope_test.rb
2014-02-17 11:21:18 -08:00
Rafael Mendonça França
141313c651 Don't skip tests if they are not broken. Just don't define they 2014-02-16 21:49:50 -03:00
Rajarshi Das
680f7d906e remove unused fixtures from sqlite3 test cases 2014-02-14 17:31:06 +05:30
Girish S
bbf6df78a4 SQLite3Adapter now checks for views in table_exists? fixes: 14041 2014-02-14 15:32:10 +05:30
Aaron Patterson
9c04b55e52 fixing explain tests for sqlite3 2014-01-17 11:14:50 -08:00
Timur Alperovich
6f16513b58 SQLite3: Always close statements.
SQLite3 adapter must make sure to close statements after queries.

Fixes: #13631
2014-01-15 10:35:21 -08:00
Aaron Patterson
ce95fb2991 "string" isn't a valid column type for ActiveRecord
Conflicts:
	activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
2014-01-14 14:01:10 -08:00
Aaron Patterson
40be2eaca9 drop the dual encodings table 2014-01-14 13:59:07 -08:00
Aaron Patterson
09035e622f Merge branch 'master' into set_binds
* master:
  don't establish a new connection when testing with `sqlite3_mem`.
  sqlite >= 3.8.0 supports partial indexes
  Don't try to get the subclass if the inheritance column doesn't exist
  Enum mappings are now exposed via class methods instead of constants.
  Fix fields_for documentation with index option [ci skip]
  quick pass through Active Record CHANGELOG. [ci skip]
  [ci skip] Grammar correction
  single quotes for controller generated routes
  [ci skip] Added alias to CSRF
  Set NameError#name
2014-01-14 11:43:57 -08:00
Yves Senn
b23330745b don't establish a new connection when testing with sqlite3_mem.
This fixes broken `rake test_sqlite3_mem` suite for Active Record.
The problem is that that the old database with the schema is lost
when establishing a new connection. Upon reconnting we are left
with a blank database and tests down the line start failing.
2014-01-14 18:03:31 +01:00
Aaron Patterson
11e8badb16 Merge branch 'master' into set_binds
* master: (2794 commits)
  doc, API example on how to use `Model#exists?` with multiple IDs. [ci skip]
  Restore DATABASE_URL even if it's nil in connection_handler test
  [ci skip] - error_messages_for has been deprecated since 2.3.8 - lets reduce any confusion for users
  Ensure Active Record connection consistency
  Revert "ask the fixture set for the sql statements"
  Check `respond_to` before delegation due to: d781caaf31
  Adding Hash#compact and Hash#compact! methods
  MySQL version 4.1 was EOL on December 31, 2009 We should at least recommend modern versions of MySQL to users.
  clear cache on body close so that cache remains during rendering
  add a more restricted codepath for templates fixes #13390
  refactor generator tests to use block form of Tempfile
  Fix typo [ci skip]
  Move finish_template as the last public method in the generator
  Minor typos fix [ci skip]
  make `change_column_null` reversible. Closes #13576.
  create/drop test and development databases only if RAILS_ENV is nil
  Revert "Speedup String#to"
  typo fix in test name. [ci skip].
  `core_ext/string/access.rb` test what we are documenting.
  Fix typo in image_tag documentation
  ...

Conflicts:
	activerecord/lib/active_record/associations/join_dependency/join_association.rb
	activerecord/lib/active_record/relation/query_methods.rb
2014-01-11 17:28:43 -08:00
schneems
f0311c2487 Raise NoDatabaseError when db does not exist
Building on the work of #13427 this PR adds a helpful error message to the adapters: mysql, mysql2, and sqlite3
2013-12-24 10:13:12 -05:00
Aaron Patterson
fbb79b517f fix url connections for sqlite3 2013-12-20 16:13:34 -08:00
Arthur Neves
4a720a2cde quoting: Check if id is a valid method before using it
Need to check if valud also respond_to :id before calling it, otherwise
things could explode.
2013-12-19 16:51:28 -05:00
Rafael Mendonça França
bd09afb5fb Don't skip tests if we don't need to.
We can conditional define the tests depending on the adapter or
connection.

Lets keep the skip for fail tests that need to be fixed.
2013-11-08 13:59:07 -02:00
Rashmi Yadav
90377f9674 Warning removed for ruby-head 2013-11-07 22:04:17 +01:00
Aaron Patterson
46c57ec4d9 stop adding singleton methods to the SQLite3 connection 2013-10-04 15:18:53 -07:00
schneems
f036239447 Create sqlite3 directory if not present
If the `db/` directory is not present on a remote machine it will blow up in unexpected ways with error messages that do not indicate there is a missing directory:

```
SQLite3::CantOpenException: unable to open database file
```

This PR checks to see if a directory exists for the sqlite3 file and if not creates it for you.

This PR is an alternative to #11692 as suggested by @josevalim
2013-08-05 12:10:52 -04:00
Antonio Santos
fb9806e5d2 Define enable_extension method to prevent undefined method error
When mixing postgresql and another adapter like sqlite3 (for dev and test
respectively), the task `db:test:prepare` will fail due to the `enable_extension`
method not being defined in the abstract adapter. This patch simply adds an
empty definition to prevent it.
2013-08-02 15:43:54 +02:00
Aaron Patterson
68a97e8118 Merge branch 'master' into experiment
* master: (49 commits)
  avoid creating a set if no where values are removed
  remove bind values for where clauses that were removed
  push partitioning up so bind elimination can get the removed wheres
  push partion logic down and initialization logic up
  the rake task `db:test:prepare` needs to load the configuration
  In batches test @total was assigned but not used. Use it in tests instead of Post.count
  partition the where values so we can access the removed ones
  eliminate some conditionals
  change method name to reflect what it actually does.
  save the where values in variables so we don't need to look them up all the time
  pass where values to the helper function rather than rely on internal state
  Spelling correction in Upgrading Guide
  Add has_named_route? to the mapper API
  No need CHANGELOG entry for a test fix
  Fix wrong `case_sensitive` in uniqueness validity test
  Fix typo in test name and documentation
  Missing ending ``` at 14.2 Merging of scopes
  copy edits[ci skip]
  Revert "Corrected documentation and added some more for the classify method in inflectors"
  Revert "Changed the CHANGELOG for active_support and improved the doc for inflector method classify"
  ...
2013-05-21 11:02:15 -07:00
Vipul A M
4237d74213 Fix typo in test name and documentation 2013-05-20 10:35:43 +05:30
Aaron Patterson
9933ab1b28 experiment 2013-05-17 15:14:22 -07:00