hi I'm quite newbie , but may be "Alias" in index block is what you need. Regards
On 12 dic, 02:02, Burt Crépeault <[email protected]> wrote: > Hi all, > > First post, great to be here and looking forward to a long successful story > with Symfony. > > I'm just starting a project with Symfony 1.4, learning the ropes (coming > from a pure SQL background, I can tell you this is a steep curve but the ol' > instinct tells me this is all worth it, pressing on...) > > My situation in a nutshell: I have two tables, both have multiple-column > primary keys and one has a multiple-column foreign key to the second. In > SQL: > > CREATE TABLE supplier_subsector ( > supplier_id integer NOT NULL, > subsector_id integer NOT NULL > ); > > ALTER TABLE ONLY supplier_subsector > ADD CONSTRAINT supplier_subsectors_pkey PRIMARY KEY (supplier_id, > subsector_id); > > CREATE TABLE supplier_request ( > supplier_id integer NOT NULL, > subsector_id integer NOT NULL, > request_id integer NOT NULL, > ); > > ALTER TABLE ONLY supplier_request > ADD CONSTRAINT supplier_request_pkey PRIMARY KEY (supplier_id, > subsector_id, request_id); > > ALTER TABLE ONLY supplier_request > ADD CONSTRAINT supplier_request_supplier_id_fkey FOREIGN KEY > (supplier_id, subsector_id) REFERENCES supplier_subsector(supplier_id, > subsector_id); > > My /config/doctrine/schema.yml model looks like this (this was all generated > by the doctrine:build-sql command, I flipped the order for clarity): > > SupplierSubsector: > connection: doctrine > tableName: supplier_subsector > columns: > supplier_id: > type: integer(4) > fixed: false > unsigned: false > primary: true > subsector_id: > type: integer(4) > fixed: false > unsigned: false > primary: true > relations: > Subsector: > local: subsector_id > foreign: id > type: one > Supplier: > local: supplier_id > foreign: id > type: one > SupplierRequest: > local: 'supplier_id, subsector_id' > foreign: 'supplier_id, subsector_id' > type: many > > SupplierRequest: > connection: doctrine > tableName: supplier_request > columns: > supplier_id: > type: integer(4) > fixed: false > unsigned: false > primary: true > subsector_id: > type: integer(4) > fixed: false > unsigned: false > primary: true > request_id: > type: integer(4) > fixed: false > unsigned: false > primary: true > relations: > Request: > local: request_id > foreign: id > type: one > SupplierSubsector: > local: 'supplier_id, subsector_id' > foreign: 'supplier_id, subsector_id' > type: one > > When trying to build this with doctrine:build --all, I get: > > SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near > "," > > LINE 1: CREATE INDEX supplier_id, subsector_id ON supplier_request > (... > > ^. Failing Query: "CREATE INDEX > supplier_id, subsector_id ON supplier_request (supplier_id, subsector_id)". > Failing Query: CREATE INDEX supplier_id, subsector_id ON supplier_request > (supplier_id, subsector_id) > > with reason, seeing that it's trying to create an index with two names. The > data/sql/schema.sql has: > > CREATE TABLE supplier_subsector (supplier_id INT, subsector_id INT, PRIMARY > KEY(supplier_id, subsector_id)); > CREATE TABLE supplier_request (supplier_id INT, subsector_id INT, request_id > INT PRIMARY KEY(supplier_id, subsector_id, request_id)); > CREATE INDEX supplier_id, subsector_id ON supplier_request (supplier_id, > subsector_id); > CREATE INDEX supplier_id, subsector_id ON supplier_subsector (supplier_id, > subsector_id); > ALTER TABLE supplier_request ADD CONSTRAINT ssss_1 FOREIGN KEY (supplier_id, > subsector_id) REFERENCES supplier_subsector(supplier_id, subsector_id) NOT > DEFERRABLE INITIALLY IMMEDIATE; > ALTER TABLE supplier_subsector ADD CONSTRAINT ssss_4 FOREIGN KEY > (supplier_id, subsector_id) REFERENCES supplier_request(supplier_id, > subsector_id) NOT DEFERRABLE INITIALLY IMMEDIATE; > > Looking at this, I notice that: > 1) the multiple-column primary keys are created ok > 2) there are (wrongly syntaxed) indexes created on the column pairs given as > foreign key references > 3) the foreign keys are created with the proper syntax > 4) the foreign keys are created both-ways (side question here: is this > because their are defined in both classes in the yml file, or because > symfony would have done it anyway?) > > So what's wrong here? > > À r'voyure, > > Burt. -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.
