<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,7 +4,7 @@
 # Invoke it as follows:
 #
 #     compare_records [--user=username] [--password=password] [--host=host] [--port=port]
-#         [--database=database]
+#         [--database=database] [--order1=order1] [--order2=order2]
 #         remap...
 #         field_names
 #         table_spec
@@ -30,6 +30,9 @@
 # This means that value1 for field in the first record set is to be taken as equivalent to
 # value2 for field in the second record set.
 #
+# The optional order1 and order2 specifications define the respective ordering of the records
+# for comparison purposes. If omitted, then the fieldname list is used.
+#
 # Written by Lawrence D'Oliveiro &lt;ldo@geek-central.gen.nz&gt;.
 #-
 
@@ -74,6 +77,8 @@ def SQLIter(Conn, Cmd, Values = None, MapFn = None) :
 		&quot;password=&quot;,
 		&quot;port=&quot;,
 		&quot;user=&quot;,
+		&quot;order1=&quot;,
+		&quot;order2=&quot;,
 		&quot;remap=&quot;,
 	]
   )
@@ -86,6 +91,8 @@ if len(Args) != 4 :
 (ArgFieldNames, TableSpec, Criteria1, Criteria2) = Args
 ConnParams = {}
 Remap = {}
+Order1 = None
+Order2 = None
 for Keyword, Value in Opts :
 	if Keyword == &quot;--database&quot; :
 		ConnParams[&quot;db&quot;] = Value
@@ -97,6 +104,10 @@ for Keyword, Value in Opts :
 		ConnParams[&quot;user&quot;] = Value
 	elif Keyword == &quot;--password&quot; :
 		ConnParams[&quot;passwd&quot;] = Value
+	elif Keyword == &quot;--order1&quot; :
+		Order1 = Value
+	elif Keyword == &quot;--order2&quot; :
+		Order2 = Value
 	elif Keyword == &quot;--remap&quot; :
 		(RemapField, RemapValue1, RemapValue2) = Value.split(&quot;:&quot;, 2)
 		if not Remap.has_key(RemapField) :
@@ -141,17 +152,24 @@ for Entry in ArgFieldNames.split(&quot;,&quot;) :
 		FieldNames.append(Entry)
 	#end if
 #end for
+if Order1 == None :
+	Order1 = &quot;, &quot;.join(FieldNames)
+#end if
+if Order2 == None :
+	Order2 = &quot;, &quot;.join(FieldNames)
+#end if
 
 Iter1 = SQLIter \
   (
 	Conn = Conn,
 	Cmd =
-			&quot;select %(fieldnames)s from %(tablespec)s where %(criteria)s order by %(fieldnames)s&quot;
+			&quot;select %(fieldnames)s from %(tablespec)s where %(criteria)s order by %(order)s&quot;
 		%
 			{
 				&quot;fieldnames&quot; : &quot;, &quot;.join(FieldNames),
 				&quot;tablespec&quot; : TableSpec,
 				&quot;criteria&quot; : Criteria1,
+				&quot;order&quot; : Order1,
 			},
 	MapFn = lambda r : tuple(str(f) for f in r)
   )
@@ -159,12 +177,13 @@ Iter2 = SQLIter \
   (
 	Conn = Conn,
 	Cmd =
-			&quot;select %(fieldnames)s from %(tablespec)s where %(criteria)s order by %(fieldnames)s&quot;
+			&quot;select %(fieldnames)s from %(tablespec)s where %(criteria)s order by %(order)s&quot;
 		%
 			{
 				&quot;fieldnames&quot; : &quot;, &quot;.join(FieldNames),
 				&quot;tablespec&quot; : TableSpec,
 				&quot;criteria&quot; : Criteria2,
+				&quot;order&quot; : Order2,
 			},
 	MapFn = lambda r : tuple(str(f) for f in r)
   )</diff>
      <filename>compare_records</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>90e87f99b58b64cec07bdb7d85858f0e201cd35d</id>
    </parent>
  </parents>
  <author>
    <name>Lawrence D'Oliveiro</name>
    <email>ldo@geek-central.gen.nz</email>
  </author>
  <url>http://github.com/ldo/bulk_copy/commit/4f36213b2b2cb6682e53e1711fa372c35249d42d</url>
  <id>4f36213b2b2cb6682e53e1711fa372c35249d42d</id>
  <committed-date>2009-10-22T20:57:05-07:00</committed-date>
  <authored-date>2009-10-22T20:57:05-07:00</authored-date>
  <message>allow user-specifiable record ordering</message>
  <tree>7f24b376b7767c9be1bb96875f008601d392a91f</tree>
  <committer>
    <name>Lawrence D'Oliveiro</name>
    <email>ldo@geek-central.gen.nz</email>
  </committer>
</commit>
