コード例 #1
0
func makePK(name string) *gorma.RelationalFieldDefinition {

	f := &gorma.RelationalFieldDefinition{}
	f.Name = dsl.SanitizeFieldName(name)
	f.DatabaseFieldName = dsl.SanitizeDBFieldName(f.Name)
	f.Datatype = gorma.PKInteger
	return f

}
コード例 #2
0
func makePK(name string) *gorma.RelationalFieldDefinition {

	f := &gorma.RelationalFieldDefinition{}
	f.FieldName = dsl.SanitizeFieldName(name)
	f.DatabaseFieldName = dsl.SanitizeDBFieldName(f.FieldName)
	f.Datatype = gorma.Integer
	f.PrimaryKey = true
	return f

}
コード例 #3
0
func TestPKWhereSingle(t *testing.T) {
	sg := &gorma.RelationalModelDefinition{}
	sg.RelationalFields = make(map[string]*gorma.RelationalFieldDefinition)
	f := &gorma.RelationalFieldDefinition{}
	f.Name = dsl.SanitizeFieldName("ID")
	f.DatabaseFieldName = dsl.SanitizeDBFieldName(f.Name)
	f.Datatype = gorma.PKInteger

	sg.RelationalFields[f.Name] = f
	sg.PrimaryKeys = append(sg.PrimaryKeys, f)

	pkw := sg.PKWhere()

	if pkw != "id = ?" {
		t.Errorf("Expected %s, got %s", "id = ?", pkw)
	}

}
コード例 #4
0
func TestPKUpdateFieldsSingle(t *testing.T) {
	sg := &gorma.RelationalModelDefinition{}
	sg.RelationalFields = make(map[string]*gorma.RelationalFieldDefinition)
	f := &gorma.RelationalFieldDefinition{}
	f.FieldName = dsl.SanitizeFieldName("ID")
	f.DatabaseFieldName = dsl.SanitizeDBFieldName(f.FieldName)
	f.Datatype = gorma.Integer
	f.PrimaryKey = true

	sg.RelationalFields[f.FieldName] = f
	sg.PrimaryKeys = append(sg.PrimaryKeys, f)

	pkw := sg.PKUpdateFields("model")

	if pkw != "model.ID" {
		t.Errorf("Expected %s, got %s", "model.ID", pkw)
	}

}