html: ~
text: ~
security: ~
- fixes: ~
+ fixes:
+ - Strip column identifiers from specified column names when mapping JDBC ResultSets to fields
changes: ~
additions: ~
dependencyChanges: ~
- contributors: ~
+ contributors:
+ - James Moger
}
#
try {
// SQLite returns pre-closed ResultSets for query results with 0 rows
if (!rs.isClosed()) {
- int[] columns = def.mapColumns(wildcardSelect, rs);
+ int[] columns = def.mapColumns(dialect, wildcardSelect, rs);
while (rs.next()) {
T item = Utils.newObject(modelClass);
def.readRow(dialect, item, rs, columns);
try {
// SQLite returns pre-closed ResultSets for query results with 0 rows
if (!rs.isClosed()) {
- int[] columns = def.mapColumns(false, rs);
+ int[] columns = def.mapColumns(db.getDialect(), false, rs);
while (rs.next()) {
T item = from.newObject();
def.readRow(db.getDialect(), item, rs, columns);
try {
// SQLite returns pre-closed ResultSets for query results with 0 rows
if (!rs.isClosed()) {
- int[] columns = def.mapColumns(false, rs);
+ int[] columns = def.mapColumns(db.getDialect(), false, rs);
while (rs.next()) {
X row = Utils.newObject(clazz);
def.readRow(db.getDialect(), row, rs, columns);
*/
String prepareStringParameter(Object o);
+ /**
+ * Returns the name of a formatted column identifier for the dialect.
+ *
+ * @param name
+ * the column name
+ * @return the column name without formatting syntax
+ */
+ String extractColumnName(String name);
+
}
return name;
}
+ @Override
+ public String extractColumnName(String name) {
+ return name.replace('\"', ' ').replace('\'', ' ').trim();
+ }
+
@Override
public <T> void prepareDropTable(SQLStatement stat, TableDefinition<T> def) {
StatementBuilder buff = new StatementBuilder("DROP TABLE IF EXISTS "
*/
public class SQLDialectMSSQL extends SQLDialectDefault {
+ @Override
+ public String extractColumnName(String name) {
+ return super.extractColumnName(name).replace('[', ' ').replace(']', ' ').trim();
+ }
+
/**
* Append limit and offset rows
*
* @param rs
* @return
*/
- int[] mapColumns(boolean wildcardSelect, ResultSet rs) {
+ int[] mapColumns(SQLDialect dialect, boolean wildcardSelect, ResultSet rs) {
int[] columns = new int[fields.size()];
for (int i = 0; i < fields.size(); i++) {
try {
if (wildcardSelect) {
// select *
// create column index by field name
- columnIndex = rs.findColumn(def.columnName);
+ columnIndex = rs.findColumn(dialect.extractColumnName(def.columnName));
} else {
// select alpha, beta, gamma, etc
// explicit select order