Skip to content

Commit 1f4a9df

Browse files
committed
Fix sql javastring order
Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>
1 parent a194e82 commit 1f4a9df

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

AndroidCodeGenerator/database_triggers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ class DatabaseTriggers(object):
3636
}
3737
<BLANKLINE>
3838
private static final String tr_archive =
39-
"CREATE TEMP TRIGGER IF NOT EXISTS tr_archive
40-
BEFORE DELETE ON notes
41-
BEGIN
42-
INSERT INTO archive (noteid,notetext) VALUES (old._id,old.text);
43-
END";
39+
"CREATE TEMP TRIGGER IF NOT EXISTS tr_archive"
40+
+" BEFORE DELETE ON notes"
41+
+" BEGIN"
42+
+" INSERT INTO archive (noteid,notetext) VALUES (old._id,old.text);"
43+
+" END";
4444
private static final String tr_log =
45-
"CREATE TRIGGER IF NOT EXISTS tr_log
46-
BEFORE UPDATE ON notes
47-
BEGIN
48-
INSERT INTO log (noteid,notetext) VALUES (new._id,new.text);
49-
END";
45+
"CREATE TRIGGER IF NOT EXISTS tr_log"
46+
+" BEFORE UPDATE ON notes"
47+
+" BEGIN"
48+
+" INSERT INTO log (noteid,notetext) VALUES (new._id,new.text);"
49+
+" END";
5050
}
5151
5252
"""
@@ -93,7 +93,7 @@ def def_triggers(self):
9393

9494
_D_T = '''
9595
private static final String {0.name} =
96-
"{0}";'''
96+
"{0.java_string}";'''
9797

9898
_C_P = '''
9999
db.execSQL("DROP TRIGGER IF EXISTS {0.name}";

AndroidCodeGenerator/db_table.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,12 @@ def __init__(self, name):
307307
self._when = None
308308
self._body = []
309309

310-
def __repr__(self):
311-
sql = self.sql_trigger()
310+
@property
311+
def java_string(self):
312+
sql = str(self)
312313
return '"\n+"'.join(sql.split('\n'))
313314

314-
def sql_trigger(self):
315+
def __repr__(self):
315316
if self._when is None:
316317
raise ValueError('You must specify a trigger time, like:\
317318
Trigger("bob").after, .before or .instead_of')

0 commit comments

Comments
 (0)