Revision 2586
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
406 | 406 |
|
407 | 407 |
##### Basic queries |
408 | 408 |
|
409 |
identifier_max_len = 64 # for both PostgreSQL and MySQL |
|
410 |
|
|
409 | 411 |
def next_version(name): |
410 |
'''Prepends the version # so it won't be removed if the name is truncated''' |
|
411 | 412 |
version = 1 # first existing name was version 0 |
412 |
match = re.match(r'^#(\d+)-(.*)$', name)
|
|
413 |
match = re.match(r'^(.*)#(\d+)$', name)
|
|
413 | 414 |
if match: |
414 |
version = int(match.group(1))+1
|
|
415 |
name = match.group(2)
|
|
416 |
return '#'+str(version)+'-'+name
|
|
415 |
name, version = match.groups()
|
|
416 |
version = int(version)+1
|
|
417 |
return strings.add_suffix(name, '#'+str(version), identifier_max_len)
|
|
417 | 418 |
|
418 | 419 |
def run_query_into(db, query, params, into=None, *args, **kw_args): |
419 | 420 |
'''Outputs a query to a temp table. |
Also available in: Unified diff
next_version(): Append the version # so it looks more natural. Take into account the max identifier length.