本文整理匯總了Golang中github.com/coopernurse/gorp.DbMap.Dialect方法的典型用法代碼示例。如果您正苦於以下問題:Golang DbMap.Dialect方法的具體用法?Golang DbMap.Dialect怎麽用?Golang DbMap.Dialect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coopernurse/gorp.DbMap
的用法示例。
在下文中一共展示了DbMap.Dialect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Query
// Query generates a Query for a target model. The target that is
// passed in must be a pointer to a struct, and will be used as a
// reference for query construction.
func Query(m *gorp.DbMap, exec gorp.SqlExecutor, target interface{}) interfaces.Query {
// Handle non-standard dialects
switch src := m.Dialect.(type) {
case gorp.MySQLDialect:
m.Dialect = dialects.MySQLDialect{src}
case gorp.SqliteDialect:
m.Dialect = dialects.SqliteDialect{src}
default:
}
plan := &QueryPlan{
dbMap: m,
executor: exec,
}
targetVal := reflect.ValueOf(target)
if targetVal.Kind() != reflect.Ptr || targetVal.Elem().Kind() != reflect.Struct {
plan.Errors = append(plan.Errors, errors.New("A query target must be a pointer to struct"))
}
targetTable, err := plan.mapTable(targetVal)
if err != nil {
plan.Errors = append(plan.Errors, err)
return plan
}
plan.target = targetVal
plan.table = targetTable
return plan
}
示例2: runQueryPlanSuite
func runQueryPlanSuite(t *testing.T, dialect gorp.Dialect, connection *sql.DB) {
dbMap := new(gorp.DbMap)
dbMap.Dialect = dialect
dbMap.Db = connection
testSuite := new(QueryPlanTestSuite)
testSuite.Map = dbMap
suite.Run(t, testSuite)
}
示例3: runQueryLanguageSuite
// TODO: DRY the suite initialization code
func runQueryLanguageSuite(t *testing.T, dialect gorp.Dialect, connection *sql.DB) {
dbMap := new(gorp.DbMap)
dbMap.Dialect = dialect
dbMap.Db = connection
//dbMap.TraceOn("TEST DB: ", log.New(os.Stdout, "", log.LstdFlags))
testSuite := new(QueryLanguageTestSuite)
testSuite.Map = dbMap
suite.Run(t, testSuite)
}