Changeset 19114 for trunk


Ignore:
Timestamp:
07/31/18 21:07:26 (6 years ago)
Author:
tbretz
Message:
Read duplicate as a vector of strings.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fits2sql.cc

    r19109 r19114  
    6363        ("engine",         var<string>(""),           "Database engine to be used when a new table is created")
    6464        ("row-format",     var<string>(""),           "Defines the ROW_FORMAT keyword for table creation")
    65         ("duplicate",      var<string>(""),           "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression")
     65        ("duplicate",      vars<string>(""),          "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression")
    6666        ("ignore-errors",  po_switch(),               "Adds the IGNORE keyword to the INSERT query (turns errors into warnings, ignores rows with errors)")
    6767        ;
     
    148148        "Usually, the INSERT query would fail if the PRIMARY key exists already. "
    149149        "This can be avoided using the 'ON DUPLICATE KEY' directive. With the "
    150         "--duplicate,you can specify what should be updated in case of a duplicate key. "
     150        "--duplicate, you can specify what should be updated in case of a duplicate key. "
    151151        "To keep the row untouched, you can just update the primary key "
    152152        "with the identical primary key, e.g. --duplicate='MyPrimary=VALUES(MyPrimary)'. "
     
    296296    const string engine          = conf.Get<string>("engine");
    297297    const string row_format      = conf.Get<string>("row-format");
    298     const string duplicate       = conf.Get<string>("duplicate");
    299298
    300299    const bool ignore_errors     = conf.Get<bool>("ignore-errors");
     
    310309    const vector<string> primary = conf.Vec<string>("primary");
    311310
     311    const vactor<string> duplicate = conf.Vec<string>("duplicate");
    312312    const vector<string> notsigned = conf.Vec<string>("unsigned");
    313313
     
    599599
    600600    if (!duplicate.empty())
    601         query += "\nON DUPLICATE KEY UPDATE\n   " + duplicate;
     601        query += "\nON DUPLICATE KEY UPDATE\n   " + boost::join(duplicate, ",\n   ");
    602602
    603603    if (verbose>0)
  • trunk/FACT++/src/root2sql.cc

    r19110 r19114  
    6666        ("engine",         var<string>(""),           "Database engine to be used when a new table is created")
    6767        ("row-format",     var<string>(""),           "Defines the ROW_FORMAT keyword for table creation")
    68         ("duplicate",      var<string>(""),           "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression")
     68        ("duplicate",      vars<string>(""),          "Specifies an assignment_list for an 'ON DUPLICATE KEY UPDATE' expression")
    6969        ("ignore-errors",  po_switch(),               "Adds the IGNORE keyword to the INSERT query (turns errors into warnings, ignores rows with errors)")
    7070        ;
     
    310310    const string engine          = conf.Get<string>("engine");
    311311    const string row_format      = conf.Get<string>("row-format");
    312     const string duplicate       = conf.Get<string>("duplicate");
     312
     313    const vector<string> duplicate = conf.Vec<string>("duplicate");
    313314
    314315    const bool ignore_errors     = conf.Get<bool>("ignore-errors");
     
    586587
    587588    if (!duplicate.empty())
    588         query += "\nON DUPLICATE KEY UPDATE\n   " + duplicate;
     589        query += "\nON DUPLICATE KEY UPDATE\n   " + boost::join(duplicate, ",\n   ");
    589590
    590591    if (verbose>0)
Note: See TracChangeset for help on using the changeset viewer.