mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
deprecate :connection and :model orm configuration options in favor of :db.
This commit is contained in:
parent
dcd1599eb4
commit
bb244a0dd7
6 changed files with 14 additions and 6 deletions
|
@ -3,12 +3,14 @@
|
||||||
== Changes
|
== Changes
|
||||||
* Remove unnecessary dependency on database_cleaner-mongo from database_cleaner-mongoid: @botandrose
|
* Remove unnecessary dependency on database_cleaner-mongo from database_cleaner-mongoid: @botandrose
|
||||||
* Enable the :cache_tables option for the mongo truncation strategy, and default to true: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
* Enable the :cache_tables option for the mongo truncation strategy, and default to true: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||||
|
* Add new :db orm configuration key, for consistency with #db and #db=. https://github.com/DatabaseCleaner/database_cleaner/pull/649
|
||||||
|
|
||||||
== Deprecations
|
== Deprecations
|
||||||
* Deprecate all #orm= setter methods: https://github.com/DatabaseCleaner/database_cleaner/pull/643
|
* Deprecate all #orm= setter methods: https://github.com/DatabaseCleaner/database_cleaner/pull/643
|
||||||
* Deprecate non-functional :reset_ids option in ActiveRecord truncation strategy: https://github.com/DatabaseCleaner/database_cleaner/issues/559
|
* Deprecate non-functional :reset_ids option in ActiveRecord truncation strategy: https://github.com/DatabaseCleaner/database_cleaner/issues/559
|
||||||
* Deprecate mongo truncation's `:cache_tables => true` option in favor of `false`, to prep for caching removal in v2.0: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
* Deprecate mongo truncation's `:cache_tables => true` option in favor of `false`, to prep for caching removal in v2.0: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||||
* Deprecate redis truncation's #url method in favor of #db: @botandrose
|
* Deprecate redis truncation's #url method in favor of #db: @botandrose
|
||||||
|
* Deprecate :connection and :model configuration options in favor of :db for consistency: https://github.com/DatabaseCleaner/database_cleaner/pull/650
|
||||||
|
|
||||||
== Bugfixes
|
== Bugfixes
|
||||||
|
|
||||||
|
|
|
@ -306,10 +306,10 @@ DatabaseCleaner[:active_record].strategy = :transaction
|
||||||
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
DatabaseCleaner[:mongo_mapper].strategy = :truncation
|
||||||
|
|
||||||
# How to specify particular connections
|
# How to specify particular connections
|
||||||
DatabaseCleaner[:active_record, { :connection => :two }]
|
DatabaseCleaner[:active_record, { :db => :two }]
|
||||||
|
|
||||||
# You may also pass in the model directly:
|
# You may also pass in the model directly:
|
||||||
DatabaseCleaner[:active_record, { :model => ModelWithDifferentConnection }]
|
DatabaseCleaner[:active_record, { :db => ModelWithDifferentConnection }]
|
||||||
```
|
```
|
||||||
|
|
||||||
Usage beyond that remains the same with `DatabaseCleaner.start` calling any setup on the different configured connections, and `DatabaseCleaner.clean` executing afterwards.
|
Usage beyond that remains the same with `DatabaseCleaner.start` calling any setup on the different configured connections, and `DatabaseCleaner.clean` executing afterwards.
|
||||||
|
|
|
@ -47,7 +47,7 @@ end
|
||||||
<tr>
|
<tr>
|
||||||
<td> Mongoid</td>
|
<td> Mongoid</td>
|
||||||
<td> <code>DatabaseCleaner[:mongoid]</code></td>
|
<td> <code>DatabaseCleaner[:mongoid]</code></td>
|
||||||
<td> Multiple databases supported for Mongoid 3. Specify <code>DatabaseCleaner[:mongoid, {:connection => :db_name}]</code> </td>
|
<td> Multiple databases supported for Mongoid 3. Specify <code>DatabaseCleaner[:mongoid, {:db => :db_name}]</code> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -47,7 +47,7 @@ end
|
||||||
<tr>
|
<tr>
|
||||||
<td>Neo4j</td>
|
<td>Neo4j</td>
|
||||||
<td><code>DatabaseCleaner[:neo4j]</code></td>
|
<td><code>DatabaseCleaner[:neo4j]</code></td>
|
||||||
<td>Database type and path(URI) <code>DatabaseCleaner[:neo4j, connection: {type: :server_db, path: 'http://localhost:7475'}].</code></td>
|
<td>Database type and path(URI) <code>DatabaseCleaner[:neo4j, db: {type: :server_db, path: 'http://localhost:7475'}].</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -49,7 +49,7 @@ Here is an overview of the supported strategies:
|
||||||
<tr>
|
<tr>
|
||||||
<td> Sequel</td>
|
<td> Sequel</td>
|
||||||
<td> <code>DatabaseCleaner[:sequel]</code></td>
|
<td> <code>DatabaseCleaner[:sequel]</code></td>
|
||||||
<td> Multiple databases supported; specify <code>DatabaseCleaner[:sequel, {:connection => Sequel.connect(uri)}]</code></td>
|
<td> Multiple databases supported; specify <code>DatabaseCleaner[:sequel, {:db => Sequel.connect(uri)}]</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -15,7 +15,13 @@ module DatabaseCleaner
|
||||||
def initialize(desired_orm = nil, opts = {})
|
def initialize(desired_orm = nil, opts = {})
|
||||||
@orm_autodetector = ORMAutodetector.new
|
@orm_autodetector = ORMAutodetector.new
|
||||||
self.orm = desired_orm
|
self.orm = desired_orm
|
||||||
self.db = opts[:connection] || opts[:model] if opts.has_key?(:connection) || opts.has_key?(:model)
|
if opts.has_key?(:model)
|
||||||
|
DatabaseCleaner.deprecate "Using the `:model` key in `DatabaseCleaner[:orm, model: ...]` is deprecated, and will be removed in database_cleaner 2.0. Please use the new `:db` key, instead, which has identical behavior: `DatabaseCleaner[:orm, db: ...]`."
|
||||||
|
end
|
||||||
|
if opts.has_key?(:connection)
|
||||||
|
DatabaseCleaner.deprecate "Using the `:connection` key in `DatabaseCleaner[:orm, connection: ...]` is deprecated, and will be removed in database_cleaner 2.0. Please use the new `:db` key, instead, which has identical behavior: `DatabaseCleaner[:orm, db: ...]`."
|
||||||
|
end
|
||||||
|
self.db = opts[:db] || opts[:connection] || opts[:model] if opts.has_key?(:db) || opts.has_key?(:connection) || opts.has_key?(:model)
|
||||||
self.strategy = orm_module && orm_module.default_strategy
|
self.strategy = orm_module && orm_module.default_strategy
|
||||||
Safeguard.new.run
|
Safeguard.new.run
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue