dabo Commit
Revision 2409
Date: 2006-10-30 19:40:34 -0800 (Mon, 30 Oct 2006)
Author: paul

Changed:
U   trunk/dabo/db/dBackend.py
U   trunk/dabo/db/dCursorMixin.py
U   trunk/dabo/lib/datanav/Form.py
U   trunk/dabo/lib/datanav/Page.py

Log:
I got tired of looking at ugly SQL, so I made a few changes to indent
the sql and show it in a monospace font. Now I'm happy.



Diff:
Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py   2006-10-30 22:13:59 UTC (rev 2408)
+++ trunk/dabo/db/dBackend.py   2006-10-31 03:40:34 UTC (rev 2409)
@@ -226,27 +226,37 @@
 
        def addField(self, clause, exp):
                """ Add a field to the field clause."""
-               return self.addWithSep(clause, exp)
+               #indent = "\t"
+               indent = len("select ") * " "
+               return self.addWithSep(clause, exp, sep=",\n%s" % indent)
 
 
        def addFrom(self, clause, exp):
                """ Add a table to the sql statement."""
-               return self.addWithSep(clause, exp)
+               #indent = "\t"
+               indent = len("select ") * " "
+               return self.addWithSep(clause, exp, sep=",\n%s" % indent)
 
 
        def addWhere(self, clause, exp, comp="and"):
                """ Add an expression to the where clause."""
-               return self.addWithSep(clause, exp, sep=" %s " % comp)
+               #indent = "\t"
+               indent = (len("select ") - len(comp)) * " "
+               return self.addWithSep(clause, exp, sep="\n%s%s " % (indent, 
comp))
 
 
        def addGroupBy(self, clause, exp):
                """ Add an expression to the group-by clause."""
-               return self.addWithSep(clause, exp)
+               #indent = "\t"
+               indent = len("select ") * " "
+               return self.addWithSep(clause, exp, sep=",\n%s" % indent)
 
 
        def addOrderBy(self, clause, exp):
                """ Add an expression to the order-by clause."""
-               return self.addWithSep(clause, exp)
+               #indent = "\t"
+               indent = len("select ") * " "
+               return self.addWithSep(clause, exp, sep=",\n%s" % indent)
 
 
        def getLimitWord(self):

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2006-10-30 22:13:59 UTC (rev 2408)
+++ trunk/dabo/db/dCursorMixin.py       2006-10-31 03:40:34 UTC (rev 2409)
@@ -1714,22 +1714,22 @@
                        whereClause = childFilterClause + " " + whereClause
 
                if fromClause: 
-                       fromClause = "from " + fromClause
+                       fromClause = "  from " + fromClause
                else:
-                       fromClause = "from " + self.sqlManager.Table
+                       fromClause = "  from " + self.sqlManager.Table
                if whereClause:
-                       whereClause = "where " + whereClause
+                       whereClause = " where " + whereClause
                if groupByClause:
-                       groupByClause = "group by " + groupByClause
+                       groupByClause = " group by " + groupByClause
                if orderByClause:
-                       orderByClause = "order by " + orderByClause
+                       orderByClause = " order by " + orderByClause
                if limitClause:
-                       limitClause = "%s %s" % 
(self.sqlManager.getLimitWord(), limitClause)
+                       limitClause = " %s %s" % 
(self.sqlManager.getLimitWord(), limitClause)
                elif limitClause is None:
                        # The limit clause was specifically disabled.
                        limitClause = ""
                else:
-                       limitClause = "%s %s" % 
(self.sqlManager.getLimitWord(), self.sqlManager._defaultLimit)
+                       limitClause = " %s %s" % 
(self.sqlManager.getLimitWord(), self.sqlManager._defaultLimit)
 
                return self.sqlManager.BackendObject.formSQL(fieldClause, 
fromClause, 
                                whereClause, groupByClause, orderByClause, 
limitClause)

Modified: trunk/dabo/lib/datanav/Form.py
===================================================================
--- trunk/dabo/lib/datanav/Form.py      2006-10-30 22:13:59 UTC (rev 2408)
+++ trunk/dabo/lib/datanav/Form.py      2006-10-31 03:40:34 UTC (rev 2409)
@@ -366,7 +366,8 @@
                if sql is None:
                        sql = "-Nothing executed yet-"
                dlg = dabo.ui.dDialog(self, Caption=_("Last SQL"))
-               eb = dlg.addObject(dabo.ui.dEditBox, ReadOnly=True, Value=sql, 
Size=(400, 400))
+               eb = dlg.addObject(dabo.ui.dEditBox, ReadOnly=True, Value=sql, 
+                               FontFace="Monospace", Size=(400, 400))
                dlg.Sizer.append1x(eb)
                dlg.show()
                dlg.release()

Modified: trunk/dabo/lib/datanav/Page.py
===================================================================
--- trunk/dabo/lib/datanav/Page.py      2006-10-30 22:13:59 UTC (rev 2408)
+++ trunk/dabo/lib/datanav/Page.py      2006-10-31 03:40:34 UTC (rev 2409)
@@ -519,7 +519,7 @@
                                sql = bizobj.getSQL()
 
                        dlg = dabo.ui.dDialog(self, Caption=_("Set Custom SQL"))
-                       eb = dlg.addObject(dabo.ui.dEditBox, Value=sql, 
Size=(400, 400))
+                       eb = dlg.addObject(dabo.ui.dEditBox, Value=sql, 
Size=(400, 400), FontFace="Monospace")
                        dlg.Sizer.append1x(eb)
                        dlg.show()
                        self.Form.CustomSQL = eb.Value




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to