"propel-gen reverse" should include VIEWs (for MySQL) #458

Closed
lathspell opened this Issue Aug 29, 2012 · 8 comments

6 participants

@lathspell

After upgrading to the latest version (1.6.7), my schema.xml does no longer include VIEWs. Before that they were created and I just had to manuall add skipSql="true" and readOnly="true" before building the models.

They should be added to the auto generated classes as building Queries for them makes absolutely sense even if they are
not writable, depending on the database.

The generation can be re-enabled with the following patch (the github viewer corrupts it, but you get the point):

--- /home/chammers/MysqlSchemaParser.php 2012-08-29 15:36:36.000000000 +0200
+++ MysqlSchemaParser.php 2012-08-29 15:30:15.000000000 +0200
@@ -100,7 +100,7 @@
$name = $row[0];
$type = $row[1];

  • - if ($name == $this->getMigrationTable() || $type != "BASE TABLE") {
  • + if ($name == $this->getMigrationTable() || !in_array($type, array("BASE TABLE", "VIEW"))) { continue; }

As said, it would be convenient if the skipSql="true" and readOnly="true" attributes would be added. At least that would made it safe to generate VIEWs until somebody enhances the code to acutally do a CREATE VIEW instead of CREATE TABLE.

@willdurand
Propel member
@willdurand
Propel member

Well, actually it's a feature, not a bug.

@willdurand willdurand closed this Dec 28, 2012
@greddyatpt

Whatever happened to this issue?

@willdurand
Propel member

Views are ignored by choice will reversing a database.

@greddyatpt

I'd like to add my vote (if it counts) for this feature. Here's a simple use case:

   use mysqldb1;
   create view user as select * from mysqldb2.user;

This view is updatable and works very similar to a table. Since Propel may not know if it's updatable or not, the developer could modify the generated schema file to indicate it.

The following workaround seems to work:

1) Create an identical local table.
2) Reverse-engineer the schema and generate the classes.
3) Replace the table with a view.

@Sorbing

Views are ignored by choice will reversing a database

@willdurand, Views still are not supported in database:reverse?

@serjoscha87

I could use this too and I think its a pitty that it has been removed. Someone got a patch for propel 2.0 already?

@motin

Here is a workaround that you can use to include views in your own projects: https://gist.github.com/motin/a44281d6c916ab343ece
(Adjust the workaround correspondingly if you use some other adapter than mysql)

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