fcf.module({
  name: "fcf:tests/NFSQL/DB.InsertAndDelete.js",
  dependencies: ["fcf:NTest/uniTest.js", "fcf:tests/NFSQL/Helpers/Helper.js"],
  module: function(uniTest, Helper) {
    uniTest.add("FSQL DB" , "DB InsertAndDelete", function(a_tester) {

      var insertId = -1;

      Helper.query(a_tester, { query: "DELETE FROM fcftest_single_types_insert1" },);

      // a_tester.actions.postAppendAC(function(){
      //   Helper.query(
      //     a_tester,
      //     { query: "INSERT INTO fcftest_single_types_insert1 (str1, text1, int1, bigint1, bool1) VALUES (${1}, ${2}, ${3}, ${4}, ${5})",
      //       args: ["test", "test_text", 1, 123, 1]
      //     },
      //     function(a_result){
      //       insertId = fcf.first2(a_result)["@key"];
      //     }
      //   );
      // });

      // a_tester.actions.postAppendAC(function(){
      //   Helper.query(
      //     a_tester, { query: "SELECT str1, text1, int1, bigint1, bool1 FROM fcftest_single_types_insert1", args: []},
      //     function(a_records){
      //       uniTest.equal(a_records, [[{"str1": "test", "text1": "test_text", "int1": 1, "bigint1": 123, "bool1": "1" }]]);
      //     });
      // });

      // a_tester.actions.postAppendAC(function(){
      //   Helper.query(a_tester, { query: "DELETE FROM fcftest_single_types_insert1 WHERE id = ${1}", args: [insertId]})
      // });

      // a_tester.actions.postAppendAC(function(){
      //   Helper.query(
      //     a_tester,
      //     { query: "INSERT INTO fcftest_single_types_insert1 (str1, text1, int1, bigint1, bool1) VALUES (${1}, ${2}, ${3}, ${4}, ${5})",
      //       args: ["test", "test_text", 1, 123, 1] },
      //       function(a_result){
      //         insertId = fcf.first2(a_result)["@key"];
      //       }
      //   );
      // });

      // a_tester.actions.postAppendAC(function(){
      //   Helper.query(
      //     a_tester, { query: "SELECT id, str1, text1, int1, bigint1, bool1 FROM fcftest_single_types_insert1", args: [1]},
      //     function(a_records){
      //       uniTest.equal(a_records, [[{"id": insertId, "str1": "test", "text1": "test_text", "int1": 1, "bigint1": 123, "bool1": "1" }]]);
      //     }
      //   )
      // });

      Helper.query(
        a_tester,
        { query: "INSERT INTO fcftest_single_types_insert1 (int1) VALUES (${1}); " +
                 "INSERT INTO fcftest_single_types_insert1 (int1) VALUES ($[0][0][@key]); " +
                 "SELECT id, int1 FROM fcftest_single_types_insert1;",
          args: [1] },
          function(a_result){
            uniTest.equal(a_result[2][1]["int1"], a_result[2][0]["id"]);
          }
      );


    });
  }
});
