 
   (testing "SQL generation flattens out embedded objects."
     (let [spec {:format :sql}
-          person-table {:name "Person" :schema nil :columns [{:name "Address" :type "OBJECT"} {:name "Name" :type "STRING"}]
+          person-table {:name "Person" :schema nil :properties [{:name "Address" :type :complex} {:name "Name" :type :string}]
                         :dependencies [{:target-schema nil :target-name "Address" :dependency-name nil :links {"Address" :embedded}}]}
           data `({:table ~person-table :tuples ~(list {:Name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
       (is (= [{:table person-table :tuples ["INSERT INTO \"Person\" (\"Name\",\"Address.Address1\",\"Address.City\") VALUES ('John Doe','123 Main','Springfield');\n"]}]

(deftest csv-formatter-test
  (testing "Generating a CSV from rows."
    (let [spec {:format :csv}
          table {:name "Example" :schema "foo" :columns '({:name "A" :type "INTEGER"} {:name "B" :type "INTEGER"})}
          rows `({:table ~table :tuples ({:A 1 :B 2})})]
      (is (= `[{:table ~table :tuples ["A,B\n1,2\n"]}]
             (format-rows spec rows)))))

  (testing "Flattens out embedded objects."
    (let [spec {:format :csv}
          person-table {:name "Person" :schema nil :columns [{:name "Address" :type "OBJECT"} {:name "Name" :type "STRING"}]
                        :dependencies [{:target-schema nil :target-name "Address" :dependency-name nil :links {"Address" :embedded}}]}
          data `({:table ~person-table :tuples ~(list {:name "John Doe" :Address {:Address1 "123 Main" :City "Springfield"}})})]
      (is (= [{:table person-table :tuples ["name,Address.Address1,Address.City\nJohn Doe,123 Main,Springfield\n"]}]

(deftest sql-formatter-test
  (testing "Basic SQL generation with integer-only values."
    (let [spec {:format :sql}
          table {:name "Example" :schema "foo" :properties '({:name "A" :type :integer} {:name "B" :type :integer})}
          rows `({:table ~table
                  :tuples ({:A 1 :B 2})})]
      (is (= '({:table {:name "Example" :schema "foo" :properties ({:name "A" :type :integer} {:name "B" :type :integer})}
                :tuples ["INSERT INTO \"foo\".\"Example\" (\"A\",\"B\") VALUES (1,2);\n"]})
             (format-rows spec rows)))))

  (testing "SQL generation quotes and escapes string values."
    (let [spec {:format :sql}
          table {:name "Example" :schema "foo" :properties '({:name "A" :type :integer} {:name "B" :type :string})}
          rows `({:table ~table
                  :tuples ({:A 1 :B  "Then O'Kelly came in with the \t hatchett."})})]
      (is (= `({:table ~table
