* 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:
Benoît Minisini 2016-01-08 14:41:23 +00:00
parent a354e12cf8
commit cf2abcd76a
3 changed files with 24 additions and 9 deletions

View file

@ -43,10 +43,18 @@ static bool exist_field(CTABLE *table, const char *name)
if (table->create)
{
for (fp = table->new_fields; fp; fp = fp->next)
{
if (table->conn->db.flags.no_case)
{
if (!strcasecmp(fp->name, name))
return TRUE;
}
else
{
if (!strcmp(fp->name, name))
return TRUE;
}
}
return FALSE;
}

View file

@ -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;
@ -227,11 +228,16 @@ BEGIN_METHOD(CINDEX_add, GB_STRING name; GB_OBJECT fields; GB_BOOLEAN unique)
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());
}

View file

@ -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);