Update sql statements don't correspond to request.form action=edit request

Update sql statements don't correspond to request.form action=edit request

bddbeditorbddbeditor Posts: 2Questions: 1Answers: 0
 Env:  .net, C#, Oracle, LeftJoin Model on 2 tables. 

Why is the second update statement missing on changes to equ_quantity fields?

------Debug Info on changing equi_quantity value
request.form
{action=edit
&data[row_1][re][requ_equipment_id]=1_
&data[row_1][ee][equi_quantity]=13}

response Queries
--"SELECT *
FROM ref_equipment re
WHERE re.requ_equipment_id = :where_0 "

--"UPDATE ref_equipment re
SET requ_equipment_id = :requ_equipment_id (missing set for equi_quantity)***
WHERE re.requ_equipment_id = :where_0 "

// Expected an update statement here for the equi_quantity field.

--"SELECT re.requ_equipment_id as \"re.requ_equipment_id\",
re.requ_nomenclature as \"re.requ_nomenclature\",
re.requ_specialty as \"re.requ_specialty\",
re.requ_provided_by as \"re.requ_provided_by\",
re.requ_notes as \"re.requ_notes\",
re.requ_enabled as \"re.requ_enabled\",
ee.equi_quantity as \"ee.equi_quantity\",
ee.equi_requ_equipment_id as \"ee.equi_requ_equipment_id\",
ee.equi_ref_id as \"ee.equi_ref_id\", ee.equi_id as \"ee.equi_id\"
FROM ref_equipment re
LEFT JOIN es_equipment ee
ON re.requ_equipment_id = ee.equi_requ_equipment_id
WHERE re.requ_equipment_id = :where_0 "

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    Can you show me both your Javascript code (for the DataTable and Editor) and the .NET code that you are using for the Editor please? I fear that this is an issue with the Editor / Oracle integration, but I'd like to make sure. It should actually write to the joined table, but I think it will throw an error due to the differently named primary key.

    Allan

  • bddbeditorbddbeditor Posts: 2Questions: 1Answers: 0
    edited August 2017

    Had to use aliases for table names because of Oracle 32char identifier limit.

    JavaScript-----------

    var editorequip = new $.fn.dataTable.Editor({
        ajax: '../dteditor/equipmente',
        table: '#dte_editEquipment',
        fields: [
             { label: 'id',   name: 're.requ_equipment_id' },
             { label: 'nomenclature',   name: 're.requ_nomenclature' },
             { label: 'provided by',    name: 're.requ_provided_by' }, 
             { label: 'notes',          name: 're.requ_notes' },
             { label: 'ee.equi_quantity',  name: 'ee.equi_quantity' }     
        ],
        formOptions: {
            inline: {
                onBlur: 'submit'
            }
        }
    });
    

    .NET code---------------------

           public JsonResult Equipmente()
            {
                var request = this.Request;
               // string[] refIds = request.Params.GetValues("equi_ref_id");
               // string refId = refIds[0];
                using (var db = new Database(DbType, DbConnection))
                {
                    var response = new Editor(db, "ref_equipment as re", "requ_equipment_id")
                        .Debug(showDebug)
                        .Model<JoinEsEquip>()
                            .LeftJoin("es_equipment ee", "re.requ_equipment_id", "=", "ee.equi_requ_equipment_id") 
                        .Process(request.Form)
                        .Data();
                    return Json(response, JsonRequestBehavior.AllowGet);
                }
            }
    

    Model<JoinEsEquip>--------------------------

    public class JoinEsEquip
    {
        public class re //ref_equipment
        {
           public Int64  requ_equipment_id { get; set; }
            public string requ_nomenclature { get; set; }
            public string requ_specialty { get; set; }
            public string requ_provided_by { get; set; }
            public string requ_notes { get; set; }
            public string requ_enabled { get; set; }
        }
        public class ee // es_euipment
        {
            public Int64 equi_quantity { get; set; }
            public Int64 equi_requ_equipment_id { get; set; }
            public Int64 equi_ref_id { get; set; }
            public Int64 equi_id { get; set; }
          //  public Int64 equi_requ_equipment_id { get; set; }
        }
    }
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    ee.equi_requ_equipment_id is the primary key for the joined table? If so, you need to include that in the field list - typically as a hidden field type.

    Allan

This discussion has been closed.