Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for ConvertMapToValuesForCreate (0.23 sec)

  1. callbacks/helper.go

    package callbacks
    
    import (
    	"reflect"
    	"sort"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    )
    
    // ConvertMapToValuesForCreate convert map to values
    func ConvertMapToValuesForCreate(stmt *gorm.Statement, mapValue map[string]interface{}) (values clause.Values) {
    	values.Columns = make([]clause.Column, 0, len(mapValue))
    	selectColumns, restricted := stmt.SelectAndOmitColumns(true, false)
    
    	keys := make([]string, 0, len(mapValue))
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 14 12:32:57 GMT 2022
    - 3.7K bytes
    - Viewed (0)
  2. callbacks/create.go

    	curTime := stmt.DB.NowFunc()
    
    	switch value := stmt.Dest.(type) {
    	case map[string]interface{}:
    		values = ConvertMapToValuesForCreate(stmt, value)
    	case *map[string]interface{}:
    		values = ConvertMapToValuesForCreate(stmt, *value)
    	case []map[string]interface{}:
    		values = ConvertSliceOfMapToValuesForCreate(stmt, value)
    	case *[]map[string]interface{}:
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 08 03:29:55 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  3. callbacks/helper_test.go

    				Columns: []clause.Column{{Name: "active"}},
    				Values:  [][]interface{}{{true}},
    			},
    		},
    	}
    
    	for _, tc := range testCase {
    		t.Run(tc.name, func(t *testing.T) {
    			actual := ConvertMapToValuesForCreate(&gorm.Statement{}, tc.input)
    			if !reflect.DeepEqual(actual, tc.expect) {
    				t.Errorf("expect %v got %v", tc.expect, actual)
    			}
    		})
    	}
    }
    
    func TestConvertSliceOfMapToValuesForCreate(t *testing.T) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Mar 05 02:22:57 GMT 2024
    - 3.4K bytes
    - Viewed (0)
Back to top