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:
parent
4a4f5d599b
commit
0a6a4672a1
2 changed files with 17 additions and 2 deletions
17
dbdimp.c
17
dbdimp.c
|
@ -1925,6 +1925,21 @@ sqlite_db_load_extension(pTHX_ SV *dbh, const char *file, const char *proc)
|
||||||
|
|
||||||
#endif
|
#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*
|
HV*
|
||||||
sqlite_db_table_column_metadata(pTHX_ SV *dbh, SV *dbname, SV *tablename, SV *columnname)
|
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
|
#endif
|
||||||
|
|
||||||
if (rc == SQLITE_OK) {
|
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, "collation_name", collseq ? newSVpv(collseq, 0) : newSV(0));
|
||||||
hv_stores(metadata, "not_null", newSViv(notnull));
|
hv_stores(metadata, "not_null", newSViv(notnull));
|
||||||
hv_stores(metadata, "primary", newSViv(primary));
|
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');
|
my $data = $dbh->$call_func(undef, 'foo', 'id', 'table_column_metadata');
|
||||||
ok $data && ref $data eq ref {}, "got a metadata";
|
ok $data && ref $data eq ref {}, "got a metadata";
|
||||||
ok $data->{auto_increment}, "id is auto incremental";
|
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->{primary}, "id is a primary key";
|
||||||
ok !$data->{not_null}, "id is not null";
|
ok !$data->{not_null}, "id is not null";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue