Lines 214-233
mu_sql_expand_query (const char *query, const char *ustr)
Link Here
|
214 |
static int |
214 |
static int |
215 |
get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) |
215 |
get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) |
216 |
{ |
216 |
{ |
217 |
const char **name = mu_assoc_ref (mu_sql_module_config.field_map, id); |
217 |
int rc; |
218 |
int rc = mu_sql_get_field (conn, 0, name ? *name : id, ret); |
218 |
const char *name = mu_assoc_get (mu_sql_module_config.field_map, id); |
|
|
219 |
if (!name) |
220 |
name = id; |
221 |
rc = mu_sql_get_field (conn, 0, name, ret); |
219 |
if (rc) |
222 |
if (rc) |
220 |
{ |
223 |
{ |
221 |
if (mandatory || rc != MU_ERR_NOENT) |
224 |
if (mandatory || rc != MU_ERR_NOENT) |
222 |
mu_error (_("cannot get SQL field `%s' (`%s'): %s"), |
225 |
mu_error (_("cannot get SQL field `%s' (`%s'): %s"), |
223 |
id, name ? *name : id, mu_strerror (rc)); |
226 |
id, name, mu_strerror (rc)); |
224 |
} |
227 |
} |
225 |
else if (!*ret) |
228 |
else if (!*ret) |
226 |
{ |
229 |
{ |
227 |
if (mandatory) |
230 |
if (mandatory) |
228 |
{ |
231 |
{ |
229 |
mu_error (_("SQL field `%s' (`%s') has NULL value"), |
232 |
mu_error (_("SQL field `%s' (`%s') has NULL value"), |
230 |
id, name ? *name : id); |
233 |
id, name); |
231 |
rc = MU_ERR_READ; |
234 |
rc = MU_ERR_READ; |
232 |
} |
235 |
} |
233 |
else |
236 |
else |
234 |
- |
|
|