|
|
@@ -130,7 +130,11 @@ class Model(object):
|
|
|
def add_foreign_key(self, name, models):
|
|
|
self.foreign_keys.append(name)
|
|
|
singular = re.sub('_' + PRIMARY_KEY + '$', '', name)
|
|
|
- other_model = find_model(singular, models)
|
|
|
+
|
|
|
+ try:
|
|
|
+ other_model = find_model(singular, models)
|
|
|
+ except ValueError:
|
|
|
+ return
|
|
|
|
|
|
self.belongs_to.append((singular, self.relopts(other_model)))
|
|
|
other_model.add_has_relation(self)
|
|
|
@@ -278,7 +282,7 @@ if __name__ == '__main__':
|
|
|
parser.add_argument('--has-one', nargs=2, dest='opt_has_one',
|
|
|
help='one-to-one relationships of the form '
|
|
|
'\'payment-receipt\', where one payment has one '
|
|
|
- 'receipt', action='append')
|
|
|
+ 'receipt', action='append', default=[])
|
|
|
parser.add_argument('--namespace', default='', dest='opt_namespace',
|
|
|
help='PHP namespace to create models classes in')
|
|
|
parser.add_argument('--create-select', action='store_true',
|