[RFR] - Manage multiple connections. Add ability to pass output dir to FixtureDumpCommand #174

Merged
merged 2 commits into from Aug 22, 2012

Projects

None yet

3 participants

  • When you have multiple connections, function loadMapBuilders() in AbstractDataHandler load all available classes into dbMap, which will cause "Base table or view not found" exception when you try to run, for example, propel:fixutres:dump --connection="default". I've added a check to verify a table is in the current database before adding it to dbMap.
  • I have also add the ability to pass an output dir as an option to fixture dump command since it was hardcoded to 'app/propel/fixtures', which is not very flexible.

This pull request passes (merged 3fb8fe5 into 4980f54).

Owner

Great!

@willdurand willdurand and 1 other commented on an outdated diff Aug 20, 2012
DataFixtures/AbstractDataHandler.php
@@ -80,6 +79,19 @@ protected function loadMapBuilders($connectionName = null)
}
/**
+ * Check if a table is in a database
+ * @param string $class
+ * @param string $connectionName
+ * @return boolean
+ */
+ protected function isInDatabase($class, $connectionName)
+ {
+ $table = new $class();
+ $tableName = $table->getClassname();
+
+ return constant(constant($tableName.'::PEER').'::DATABASE_NAME') == $connectionName;
+ }
willdurand
willdurand Aug 20, 2012 Owner

Can you add a blank line here please?

@willdurand willdurand and 1 other commented on an outdated diff Aug 20, 2012
DataFixtures/AbstractDataHandler.php
@@ -80,6 +79,19 @@ protected function loadMapBuilders($connectionName = null)
}
/**
+ * Check if a table is in a database
+ * @param string $class
+ * @param string $connectionName
+ * @return boolean
+ */
+ protected function isInDatabase($class, $connectionName)
+ {
+ $table = new $class();
+ $tableName = $table->getClassname();
willdurand
willdurand Aug 20, 2012 Owner

Isn't there a constant for that?

passkey1510
passkey1510 Aug 20, 2012

return constant($table->getPeerClassname().'::DATABASE_NAME') == $connectionName;

This is the shortest way I could found, if you have another idea :)

Anh Tuan Kieu Fix code review e27bbe9

This pull request passes (merged e27bbe9 into 4980f54).

Hello, I've made the fix based on your code review, is it ok for you?

@willdurand willdurand merged commit 9d6fa89 into propelorm:1.1 Aug 22, 2012

1 check passed

default The Travis build passed
Details
Owner

Yes sorry, merged! Thanks for your work.

Nice, thank you very much!

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