Mercurial > hg > orthanc-databases
comparison Framework/Common/GenericFormatter.cpp @ 302:3a52e27a2d80
in GenericFormatter, replaced ${} by ${AUTOINCREMENT}
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Jul 2021 16:25:08 +0200 |
parents | 70685295a373 |
children | 495b6f325e35 |
comparison
equal
deleted
inserted
replaced
301:2447c290fc73 | 302:3a52e27a2d80 |
---|---|
31 const std::string& source, | 31 const std::string& source, |
32 ValueType type) | 32 ValueType type) |
33 { | 33 { |
34 if (source.empty()) | 34 if (source.empty()) |
35 { | 35 { |
36 // This is the default parameter for INSERT | 36 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
37 } | |
38 else if (source == "AUTOINCREMENT") | |
39 { | |
40 if (GetParametersCount() != 0) | |
41 { | |
42 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, | |
43 "The AUTOINCREMENT argument must always be the first"); | |
44 } | |
45 | |
37 switch (dialect_) | 46 switch (dialect_) |
38 { | 47 { |
39 case Dialect_PostgreSQL: | 48 case Dialect_PostgreSQL: |
40 target = "DEFAULT"; | 49 target = "DEFAULT, "; |
41 break; | 50 break; |
42 | 51 |
43 case Dialect_MySQL: | 52 case Dialect_MySQL: |
44 case Dialect_SQLite: | 53 case Dialect_SQLite: |
45 target = "NULL"; | 54 target = "NULL, "; |
55 break; | |
56 | |
57 case Dialect_MSSQL: | |
58 target.clear(); // The IDENTITY field must not be filled in MSSQL | |
46 break; | 59 break; |
47 | 60 |
48 default: | 61 default: |
49 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 62 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
50 } | 63 } |
51 } | 64 } |
52 else | 65 else |
53 { | 66 { |
54 if (allNames_.find(source) != allNames_.end()) | |
55 { | |
56 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, | |
57 "Parameter ${" + source + "} registered twice"); | |
58 } | |
59 | |
60 allNames_.insert(source); | |
61 | |
62 switch (dialect_) | 67 switch (dialect_) |
63 { | 68 { |
64 case Dialect_PostgreSQL: | 69 case Dialect_PostgreSQL: |
65 target = "$" + boost::lexical_cast<std::string>(parametersName_.size() + 1); | 70 target = "$" + boost::lexical_cast<std::string>(parametersName_.size() + 1); |
66 break; | 71 break; |