diff --git a/CHANGELOG b/CHANGELOG index d84f0ee..0deb2f2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 2.6 - Improved survey sending +- Prevent names from being reserved keywords 2.5 - Add new class of tests for queries that are supposed to fail diff --git a/relational/rtypes.py b/relational/rtypes.py index 1c9dce0..805d9f4 100644 --- a/relational/rtypes.py +++ b/relational/rtypes.py @@ -1,5 +1,5 @@ # Relational -# Copyright (C) 2008-2016 Salvo "LtWorf" Tomaselli +# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli # # Relation is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ # implementing dates to use in selection. import datetime +import keyword import re RELATION_NAME_REGEXP = re.compile(r'^[_a-z][_a-z0-9]*$', re.IGNORECASE) @@ -161,7 +162,8 @@ class Rdate (object): def is_valid_relation_name(name): '''Checks if a name is valid for a relation. Returns boolean''' - return re.match(RELATION_NAME_REGEXP, name) != None + return re.match(RELATION_NAME_REGEXP, name) != None and not keyword.iskeyword(name) + # Backwards compatibility rdate = Rdate