Example #1
0
func init() {
	pop.Debug = false
	pop.AddLookupPaths("./")

	dialect := os.Getenv("SODA_DIALECT")

	var err error
	PDB, err = pop.Connect(dialect)
	if err != nil {
		log.Panic(err)
	}

	pop.MapTableName("Friend", "good_friends")
	pop.MapTableName("Friends", "good_friends")
}
Example #2
0
func Test_MapTableName(t *testing.T) {
	r := require.New(t)

	pop.MapTableName("Friend", "good_friends")

	m := pop.Model{Value: Friend{}}
	r.Equal(m.TableName(), "good_friends")

	m = pop.Model{Value: &Friend{}}
	r.Equal(m.TableName(), "good_friends")

	m = pop.Model{Value: &Friends{}}
	r.Equal(m.TableName(), "good_friends")

	m = pop.Model{Value: []Friend{}}
	r.Equal(m.TableName(), "good_friends")

	m = pop.Model{Value: &[]Friend{}}
	r.Equal(m.TableName(), "good_friends")
}