Fixes for 105 (lighthouse): Saving habtm between different db-schemas #272

Merged
merged 8 commits into from Nov 29, 2011

Conversation

Projects
None yet
2 participants
@rchavik
Member

rchavik commented Oct 24, 2011

DboSource::buildJoinStatement compares its own database against the
corresponding join Model database. This is required for habtm cross-db
find() operation to work.

Model::save uses joined Model's datasource instead of its own when
saving HABTM relationship.

Depends on: #271
Obsoletes: #262

@rchavik

This comment has been minimized.

Show comment Hide comment
@rchavik

rchavik Nov 5, 2011

Member

I have revised this pull request. It broke my croogo plugin.

So I have reverted the approach back to the original version created during 1.3.

If you need the original diff for this pull request, it's in rchavik/cakephp@cakephp:2.1...rchavik:#105.bak

NOTE: This depends onn #271 -> Multi-db fixture

Member

rchavik commented Nov 5, 2011

I have revised this pull request. It broke my croogo plugin.

So I have reverted the approach back to the original version created during 1.3.

If you need the original diff for this pull request, it's in rchavik/cakephp@cakephp:2.1...rchavik:#105.bak

NOTE: This depends onn #271 -> Multi-db fixture

@rchavik

This comment has been minimized.

Show comment Hide comment
@rchavik

rchavik Nov 21, 2011

Member

Since #271 has now been merged in, can I please get some input about this pull request:

  • A new property Model::$schemaName. The value should be 'read only', and populated by the model's datasource (see next point)
  • A new method in DboSource::getSchemaName(). Each database will need to override this method and return the appropriate schema name accordingly.
  • Model::fullTableName() will include the 'schema' name prepended by default. Passing false to the third argument turns this off.

These are added so that SQL queries will have the relevant schema name. For example:

create table schema.table_1 ( id integer );
select * 
  from `schema1`.`users` as `User` join `schema2`.`groups` as `Group`
    on `User`.`group_id` = `Group`.`id`

Here's a link to a diff of this pull request for the first 3 commits (without the test): rchavik/cakephp@cakephp:2.1...rchavik:8c2f8ac

FYI, I've just rebased, so diff of relevant commits is in rchavik/cakephp@cakephp:2.1...rchavik:fd07b96

Member

rchavik commented Nov 21, 2011

Since #271 has now been merged in, can I please get some input about this pull request:

  • A new property Model::$schemaName. The value should be 'read only', and populated by the model's datasource (see next point)
  • A new method in DboSource::getSchemaName(). Each database will need to override this method and return the appropriate schema name accordingly.
  • Model::fullTableName() will include the 'schema' name prepended by default. Passing false to the third argument turns this off.

These are added so that SQL queries will have the relevant schema name. For example:

create table schema.table_1 ( id integer );
select * 
  from `schema1`.`users` as `User` join `schema2`.`groups` as `Group`
    on `User`.`group_id` = `Group`.`id`

Here's a link to a diff of this pull request for the first 3 commits (without the test): rchavik/cakephp@cakephp:2.1...rchavik:8c2f8ac

FYI, I've just rebased, so diff of relevant commits is in rchavik/cakephp@cakephp:2.1...rchavik:fd07b96

rchavik added some commits Nov 5, 2011

Adding new property Model::schemaName
Just like physical table name, the schema name is an important information
that should be available in models.  The property will be populated accordingly
by the model's datasource.
In a multidb habtm, we cannot rely on 'joinTable'
Instead, we should use value from 'with' when it's available.
fixing broken tests: updating fullTableName() use
At the same time, reversing arguments since phpunit wants 'expected' as
the first parameter.

@lorenzo lorenzo merged commit 6874e49 into cakephp:2.1 Nov 29, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment