[GB.DB]
* BUG: Take case-sensitive databases like postgresql into account in index fields. git-svn-id: svn://localhost/gambas/trunk@7564 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
a354e12cf8
commit
cf2abcd76a
3 changed files with 24 additions and 9 deletions
|
@ -44,8 +44,16 @@ static bool exist_field(CTABLE *table, const char *name)
|
|||
{
|
||||
for (fp = table->new_fields; fp; fp = fp->next)
|
||||
{
|
||||
if (!strcmp(fp->name, name))
|
||||
return TRUE;
|
||||
if (table->conn->db.flags.no_case)
|
||||
{
|
||||
if (!strcasecmp(fp->name, name))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strcmp(fp->name, name))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -141,10 +141,10 @@ BEGIN_PROPERTY(CINDEX_fields)
|
|||
GB_ARRAY array;
|
||||
char *fields;
|
||||
char *name;
|
||||
|
||||
|
||||
fields = GB.NewZeroString(THIS->info.fields);
|
||||
GB.Array.New(&array, GB_T_STRING, 0);
|
||||
|
||||
|
||||
name = strtok(fields, ",");
|
||||
while (name)
|
||||
{
|
||||
|
@ -214,6 +214,7 @@ BEGIN_METHOD(CINDEX_add, GB_STRING name; GB_OBJECT fields; GB_BOOLEAN unique)
|
|||
DB_INDEX info;
|
||||
int i;
|
||||
GB_ARRAY fields;
|
||||
char *field;
|
||||
|
||||
if (DB_CheckNameWith(name, "index", "."))
|
||||
return;
|
||||
|
@ -222,24 +223,29 @@ BEGIN_METHOD(CINDEX_add, GB_STRING name; GB_OBJECT fields; GB_BOOLEAN unique)
|
|||
return;
|
||||
|
||||
info.name = name;
|
||||
|
||||
|
||||
fields = (GB_ARRAY)VARG(fields);
|
||||
q_init();
|
||||
for (i = 0; i < GB.Array.Count(fields); i++)
|
||||
{
|
||||
field = *(char **)GB.Array.Get(fields, i);
|
||||
|
||||
if (i > 0)
|
||||
q_add(",");
|
||||
|
||||
|
||||
q_add(table->driver->GetQuote());
|
||||
q_add(*(char **)GB.Array.Get(fields, i));
|
||||
if (table->conn->db.flags.no_case)
|
||||
q_add_lower(field);
|
||||
else
|
||||
q_add(field);
|
||||
q_add(table->driver->GetQuote());
|
||||
}
|
||||
|
||||
|
||||
info.fields = q_steal();
|
||||
info.unique = VARGOPT(unique, FALSE);
|
||||
|
||||
table->driver->Index.Create(&table->conn->db, table->name, name, &info);
|
||||
|
||||
|
||||
GB.FreeString(&info.fields);
|
||||
|
||||
END_METHOD
|
||||
|
|
|
@ -55,6 +55,7 @@ void DB_TryAnother(const char *);
|
|||
|
||||
void q_init(void);
|
||||
void q_add(const char *str);
|
||||
void q_add_lower(const char *str);
|
||||
void q_add_length(const char *str, int len);
|
||||
char *q_get(void);
|
||||
char *q_steal(void);
|
||||
|
|
Loading…
Reference in a new issue