QString fname = qGetStringData(hStmt, 3, -1, p->unicode);
int type = qGetIntData(hStmt, 4).toInt(); // column type
QSqlField f(fname, qDecodeODBCType(type, p));
+ QVariant var = qGetIntData(hStmt, 6);
+ f.setLength(var.isNull() ? -1 : var.toInt()); // column size
+ var = qGetIntData(hStmt, 8).toInt();
+ f.setPrecision(var.isNull() ? -1 : var.toInt()); // precision
+ f.setSqlType(type);
int required = qGetIntData(hStmt, 10).toInt(); // nullable-flag
// required can be SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN
if (required == SQL_NO_NULLS)
else if (required == SQL_NULLABLE)
f.setRequired(false);
// else we don't know
- QVariant var = qGetIntData(hStmt, 6);
- f.setLength(var.isNull() ? -1 : var.toInt()); // column size
- var = qGetIntData(hStmt, 8).toInt();
- f.setPrecision(var.isNull() ? -1 : var.toInt()); // precision
- f.setSqlType(type);
return f;
}
QSqlRecord rec = db.driver()->record(tablename);
QCOMPARE(rec.count(), 4);
+ // QTBUG-1363: QSqlField::length() always return -1 when using QODBC3 driver and QSqlDatabase::record()
+ if (db.driverName().startsWith("QODBC") && tst_Databases::isSqlServer(db))
+ QCOMPARE(rec.field(1).length(), 20);
+
if (db.driverName().startsWith("QIBASE")|| db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2"))
for(int i = 0; i < fields.count(); ++i)
fields[i] = fields[i].toUpper();