tickets_full: 166

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
166 2005-07-22 20:10:11 2007-07-03 23:04:18 2019-06-24 00:17:02.256922 Design decision needed closed Core (Other) enhancement normal   fixed [patch] Add "in" to the lookup types in the DB API This patch allows one to do {{{field__in=[1,4,7,10]}}} to select a non-contiguous set of values in a single SELECT statement, which will look like this in SQL: {{{SELECT * FROM table WHERE field IN (1,4,7,10)}}} {{{ Index: django/core/meta.py =================================================================== --- django/core/meta.py (revision 299) +++ django/core/meta.py (working copy) -1018,7 +1020,10 @@ return '%s%s %s %%s' % (table_prefix, field_name, db.OPERATOR_MAPPING[lookup_type]) except KeyError: pass - if lookup_type in ('range', 'year'): + if lookup_type == 'in': + in_clause = ','.join(['%s']*len(value)) + return '%s%s IN (%s)' % (table_prefix, field_name, in_clause) + elif lookup_type in ('range', 'year'): return '%s%s BETWEEN %%s AND %%s' % (table_prefix, field_name) elif lookup_type in ('month', 'day'): return "%s = %%s" % db.get_date_extract_sql(lookup_type, table_prefix + field_name) -1630,7 +1635,7 @@ "Returns field's value prepared for database lookup." if lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne', 'month', 'day'): return [value] - elif lookup_type == 'range': + elif lookup_type in ('range', 'in'): return value elif lookup_type == 'year': return ['%s-01-01' % value, '%s-12-31' % value] }}} adrian rmunn@pobox.com   0 1 0 0 0 0
Powered by Datasette · Query took 1.719ms