[ 
https://issues.apache.org/jira/browse/METAMODEL-131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14481453#comment-14481453
 ] 

ASF GitHub Bot commented on METAMODEL-131:
------------------------------------------

Github user kaspersorensen commented on the pull request:

    https://github.com/apache/metamodel/pull/14#issuecomment-90161694
  
    Thanks for the patch, but I don't think this approach will fly. First I 
have to mention that there are code styling issues (tabs instead of spaces, no 
spaces in front of parenthesis etc.) but that's less important right now ...
    
    Important part is: Different databases have different SQL dialects and in 
this patch it is proposed to switch from one dialect (that was very common but 
less flexible) to the other dialect which is AFAIK less supported.
    
    Here's some sources of inspiration maybe:
    
    [1] http://www.w3schools.com/sql/sql_primarykey.asp
    [2] http://www.techonthenet.com/sql/primary_keys.php
    
    To make this work we should only touch the JdbcCreateTableBuilder IMO. The 
abstract one is not supposed/guaranteed to generate perfect SQL for all 
databases, just like Query.toSql() will not generate SQL that is working on all 
databases. It is in the concrete implementation of CreateTableBuilder that we 
figure that part out (and in non-JDBC modules it is not a CREATE TABLE 
statement but some other operation anyway).
    
    The JdbcCreateTableBuilder should take advice or delegate to the 
QueryRewriter interface. This is our current mechanism to allow different 
databases to have different dialects. I suggest we continue with that approach 
unless there's some better idea.


> Create table with composite primary key gives error.
> ----------------------------------------------------
>
>                 Key: METAMODEL-131
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-131
>             Project: Apache MetaModel
>          Issue Type: Bug
>            Reporter: Hosur Narahari
>
> Creating table with primary key is not possible since while generating sql we 
> add "PRIMARY KEY" keyword to each column which results in error in case of 
> composite primary keys. Below is the code.
> context.executeUpdate(new UpdateScript() {
>                       
>                       @Override
>                       public void run(UpdateCallback callback) {
>                               callback.createTable("amass", "test").
>                               
> withColumn("id").ofType(ColumnType.INTEGER).ofSize(16).asPrimaryKey()
>                               
> .withColumn("name").ofType(ColumnType.VARCHAR).ofSize(255).asPrimaryKey()
>                               .execute();
>                       }
>               });
> I am using mysql. Am I using it in the wrong way?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to