@@ -832,7 +832,7 @@ void DataMapper::Update(Record& record)
832832    {
833833        if  (record.[:el:].IsModified ())
834834        {
835-             _stmt.BindInputParameter (i++, record.[:el:].Value (), std::meta::identifier_of (el) );
835+             _stmt.BindInputParameter (i++, record.[:el:].Value (), FieldNameOf<el> );
836836        }
837837    }
838838
@@ -841,23 +841,21 @@ void DataMapper::Update(Record& record)
841841        using  FieldType = typename [:std::meta::type_of (el):];
842842        if  constexpr  (FieldType::IsPrimaryKey)
843843        {
844-             _stmt.BindInputParameter (i++, record.[:el:].Value (), std::meta::identifier_of (el) );
844+             _stmt.BindInputParameter (i++, record.[:el:].Value (), FieldNameOf<el> );
845845        }
846846    }
847847#else 
848848    //  Bind the SET clause
849-     Reflection::CallOnMembers (
850-         record, [this , &i]<typename  Name, typename  FieldType>(Name const & name, FieldType const & field) mutable  {
851-             if  (field.IsModified ())
852-                 _stmt.BindInputParameter (i++, field.Value (), name);
853-         });
849+     Reflection::CallOnMembersWithoutName (record, [this , &i]<size_t  I, typename  FieldType>(FieldType const & field) {
850+         if  (field.IsModified ())
851+             _stmt.BindInputParameter (i++, field.Value (), FieldNameAt<I, Record>);
852+     });
854853
855854    //  Bind the WHERE clause
856-     Reflection::CallOnMembers (
857-         record, [this , &i]<typename  Name, typename  FieldType>(Name const & name, FieldType const & field) mutable  {
858-             if  constexpr  (FieldType::IsPrimaryKey)
859-                 _stmt.BindInputParameter (i++, field.Value (), name);
860-         });
855+     Reflection::CallOnMembersWithoutName (record, [this , &i]<size_t  I, typename  FieldType>(FieldType const & field) {
856+         if  constexpr  (IsPrimaryKey<Reflection::MemberTypeOf<I, Record>>)
857+             _stmt.BindInputParameter (i++, field.Value (), FieldNameAt<I, Record>);
858+     });
861859#endif 
862860
863861    _stmt.Execute ();
@@ -878,14 +876,13 @@ std::size_t DataMapper::Delete(Record const& record)
878876    {
879877        using  FieldType = typename [:std::meta::type_of (el):];
880878        if  constexpr  (FieldType::IsPrimaryKey)
881-             std::ignore = query.Where (std::meta::identifier_of (el) , SqlWildcard);
879+             std::ignore = query.Where (FieldNameOf<el> , SqlWildcard);
882880    }
883881#else 
884-     Reflection::CallOnMembers (record,
885-                               [&query]<typename  Name, typename  FieldType>(Name const & name, FieldType const & /* field*/  ) {
886-                                   if  constexpr  (FieldType::IsPrimaryKey)
887-                                       std::ignore = query.Where (name, SqlWildcard);
888-                               });
882+     Reflection::CallOnMembersWithoutName (record, [&query]<size_t  I, typename  FieldType>(FieldType const & /* field*/  ) {
883+         if  constexpr  (IsPrimaryKey<Reflection::MemberTypeOf<I, Record>>)
884+             std::ignore = query.Where (FieldNameAt<I, Record>, SqlWildcard);
885+     });
889886#endif 
890887
891888    _stmt.Prepare (query);
@@ -897,16 +894,15 @@ std::size_t DataMapper::Delete(Record const& record)
897894        using  FieldType = typename [:std::meta::type_of (el):];
898895        if  constexpr  (FieldType::IsPrimaryKey)
899896        {
900-             _stmt.BindInputParameter (i++, record.[:el:].Value (), std::meta::identifier_of (el) );
897+             _stmt.BindInputParameter (i++, record.[:el:].Value (), FieldNameOf<el> );
901898        }
902899    }
903900#else 
904901    //  Bind the WHERE clause
905-     Reflection::CallOnMembers (
906-         record,
907-         [this , i = SQLSMALLINT { 1  }]<typename  Name, typename  FieldType>(Name const & name, FieldType const & field) mutable  {
908-             if  constexpr  (FieldType::IsPrimaryKey)
909-                 _stmt.BindInputParameter (i++, field.Value (), name);
902+     Reflection::CallOnMembersWithoutName (
903+         record, [this , i = SQLSMALLINT { 1  }]<size_t  I, typename  FieldType>(FieldType const & field) mutable  {
904+             if  constexpr  (IsPrimaryKey<Reflection::MemberTypeOf<I, Record>>)
905+                 _stmt.BindInputParameter (i++, field.Value (), FieldNameAt<I, Record>);
910906        });
911907#endif 
912908
0 commit comments