mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-06 21:58:01 -04:00
Lowercase datatype
This commit is contained in:
parent
2d595f3bf2
commit
abc241d711
2 changed files with 17 additions and 2 deletions
17
dbdimp.c
17
dbdimp.c
|
@ -1928,6 +1928,21 @@ sqlite_db_load_extension(pTHX_ SV *dbh, const char *file, const char *proc)
|
|||
|
||||
#endif
|
||||
|
||||
SV* _lc(SV* sv) {
|
||||
int i, l;
|
||||
char* pv;
|
||||
if (SvPOK(sv)) {
|
||||
pv = SvPV_nolen(sv);
|
||||
l = strlen(pv);
|
||||
for(i = 0; i < l; i++) {
|
||||
if (pv[i] >= 'A' && pv[i] <= 'Z') {
|
||||
pv[i] = pv[i] - 'A' + 'a';
|
||||
}
|
||||
}
|
||||
}
|
||||
return sv;
|
||||
}
|
||||
|
||||
HV*
|
||||
sqlite_db_table_column_metadata(pTHX_ SV *dbh, SV *dbname, SV *tablename, SV *columnname)
|
||||
{
|
||||
|
@ -1964,7 +1979,7 @@ sqlite_db_table_column_metadata(pTHX_ SV *dbh, SV *dbname, SV *tablename, SV *co
|
|||
#endif
|
||||
|
||||
if (rc == SQLITE_OK) {
|
||||
hv_stores(metadata, "data_type", datatype ? newSVpv(datatype, 0) : newSV(0));
|
||||
hv_stores(metadata, "data_type", datatype ? _lc(newSVpv(datatype, 0)) : newSV(0));
|
||||
hv_stores(metadata, "collation_name", collseq ? newSVpv(collseq, 0) : newSV(0));
|
||||
hv_stores(metadata, "not_null", newSViv(notnull));
|
||||
hv_stores(metadata, "primary", newSViv(primary));
|
||||
|
|
|
@ -19,7 +19,7 @@ for my $call_func (@CALL_FUNCS) {
|
|||
my $data = $dbh->$call_func(undef, 'foo', 'id', 'table_column_metadata');
|
||||
ok $data && ref $data eq ref {}, "got a metadata";
|
||||
ok $data->{auto_increment}, "id is auto incremental";
|
||||
is lc($data->{data_type}) => 'integer', "data type is correct";
|
||||
is $data->{data_type} => 'integer', "data type is correct";
|
||||
ok $data->{primary}, "id is a primary key";
|
||||
ok !$data->{not_null}, "id is not null";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue