1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

Lowercase datatype

This commit is contained in:
Kenichi Ishigaki 2022-02-26 11:10:42 +09:00
parent 4a4f5d599b
commit 0a6a4672a1
2 changed files with 17 additions and 2 deletions

View file

@ -1925,6 +1925,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)
{
@ -1961,7 +1976,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));

View file

@ -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";
}