GithubHelp home page GithubHelp logo

cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

Remove useless annotations

As scrutinizer states, it is not necessary to specify @return on a constructor in the auto structure classes.

Namespace generation for simple projects

The readme states that generated classes are saved under DatabaseConfigName\SchemaSchema.
This is a fine default as it works well for both a multi-database & schemata config and a simple single database and schema using PSR-0, but doesn't work for those of us using PSR-4 for our application namespace and wanting to have our entities generated in the same namespace.

I get that using the DatabaseConfigName\SchemaSchema layout makes sense for multiple schemata and multiple database configurations, but I think it would be nice for a simple application to have generated files in a simpler structure with:

$ ./bin/pomm.php pomm:generate:schema-all --prefix-dir sources/lib --prefix-ns Model pomm_test
 ✓  Creating file 'sources/lib/Model/AutoStructure/Pika.php'.
…

Where the Pika class is in the DatabaseConfigName\Model\AutoStructure namespace (or not? It's just an extra bit to add to --prefix-ns).

Is this remotely feasible and does it make sense? I thought I'd check before diving in to the code.

Outdated Composer lock file (Semver to the rescue?)

Pomm's Cli often calls Session::getInspector(), that actually belong to a more recent version of the Foundation's Session class coming from the Foundation version referenced in the composer.lock.
So you need to run composer update to get those new Session features.

Not sure about how composer constraints + following semantic versioning may help preventing this.

Update primary key in AutoStructure

I have a table:

CREATE TABLE IF NOT EXISTS orga.activity (
    activity_id serial PRIMARY KEY,
    name varchar NOT NULL,
    project_id int NOT NULL REFERENCES orga.project(project_id) ON DELETE CASCADE
);

Then I rename the primary key:

ALTER TABLE orga.activity RENAME COLUMN id TO activity_id;

And regenerate the AutoStructure files (symfony):

./bin/console pomm:generate:schema-all -d engine -a OrgaBundle model orga

Overwriting file 'engine/OrgaBundle/Model/OrgaSchema/AutoStructure/Activity.php'.

Now if I open AutoStructure/Activity.php I see:

            ->setRelation('orga.activity')
            ->setPrimaryKey(['id'])
            ->addField('activity_id', 'int4')
            ->addField('name', 'varchar')
            ->addField('project_id', 'int4')

->addField('id', 'int4') is overwritten with "->addField('activity_id', 'int4')" but the Primary Key isn't overwritten with the new primary key name.

The table seems to have correct structure:

\d activity


   Column    |       Type        |                       Modifiers                       
-------------+-------------------+-------------------------------------------------------
 activity_id | integer           | not null default nextval('activity_id_seq'::regclass)
 name        | character varying | not null
 project_id  | integer           | not null
Indexes:
    "activity_pkey" PRIMARY KEY, btree (activity_id)
Foreign-key constraints:
    "activity_project_id_fkey" FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE

[Question] what about migrations?

Hello everibody!

Awesome project! Looks very cool!

One question: how can i mirgate my schema and some data with versioning?

Is where something like doctrine-migrations for Pomm?

Absolute Path with option --prefix-dir

Hello,
I discover a light bug with prefix option, the first slash are remove by ltrim.
I don't know why ltrim is there, that should be rtrim no ? for avoid double slash at right if path end with slash.

# https://github.com/pomm-project/Cli/blob/master/sources/lib/Command/SchemaAwareCommand.php#L138
$elements =
  [
    ltrim($this->prefix_dir, '/'),
    $prefix_ns,
    Inflector::studlyCaps($config_name),
    Inflector::studlyCaps(sprintf("%s_schema", $this->schema)),
    $extra_dir,
    sprintf("%s%s.php", Inflector::studlyCaps($file_name), $file_suffix)
  ];
$ php /app/vendor/bin/pomm.php pomm:generate:schema-all -b /app/.pomm_cli_bootstrap.php \ 
 --prefix-dir /app/src//// \
 --prefix-ns "\Plab\Iced\Core" \
 --psr4

# with ltrim
app/src/////Model/CatalogSchema/AutoStructure/Attribute.php

# with rtrim
/app/src/Model/CatalogSchema/AutoStructure/Attribute.php

# when ltrim removed
/app/src/////Model/CatalogSchema/AutoStructure/Attribute.php

Misleading Session object passed to BaseGenerator

=> PommProject\Cli\Test\Unit\Command\GenerateEntity::testExecute():
==> Error CATCHABLE FATAL ERROR in /home/travis/build/pomm-project/Cli/sources/tests/Unit/Command/GenerateEntity.php on unknown line, generated by file /home/travis/build/pomm-project/Cli/vendor/pomm-project/model-manager/sources/lib/Generator/BaseGenerator.php on line 54:
Argument 1 passed to PommProject\ModelManager\Generator\BaseGenerator::__construct() must be an instance of PommProject\ModelManager\Session, instance of PommProject\Foundation\Session given, called in /home/travis/build/pomm-project/Cli/sources/lib/Command/GenerateEntity.php on line 85 and defined

See https://travis-ci.org/pomm-project/Cli/jobs/64483005

Escaping of reserved words in schema name

If we create schema with name "user" cli generator should create relations with escaped schema name as it's reserved word. E.g.

AutoStructure/Table.php should contains ->setRelation('"user".table') instead of ->setRelation('user.table')

Default directory structure without 'Mydb\PublicSchema'

I originally created this in wrong project pomm-bundle pomm-project/pomm-bundle#42.

Pomm generates model, structure and other files to directory structure Connectionalias\Schema. If I have only one connection to DB, which I believe is very common scenario, I think that there could be something like "default connction" which will ommit this in namespace and in path. In result there will be only src/AppBundle/Model/ instead of src/AppBundle/Model/Mydb/PublicSchema/.

Including @property in generated entities

Currently, entities are generated without any property annotation, so code completion in editors is not supported.

One possibility (in my opinion the cleanest one) would be, to change the entity template like this:

namespace {:namespace:};

use {:flexible_container:};

/**
 * {:entity:}
 *
 * Flexible entity for relation
 * {:schema:}.{:relation:}
 *
 * @see FlexibleEntity
 * 
 * @property String name
 * @property Integer ....
 */
class {:entity:} extends {:flexible_container_class:}
{
}

Now $entity->name is available as a code completion suggestion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.