Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
Add context support (#46)
Browse files Browse the repository at this point in the history
* add context support

* fix config

* fix circle config

* golang test to go1.10
  • Loading branch information
lunny committed Jan 17, 2019
1 parent 6bc9412 commit f50e09f
Show file tree
Hide file tree
Showing 23 changed files with 460 additions and 234 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.8
- image: circleci/golang:1.10

# CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/
- image: circleci/mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: core_test
MYSQL_HOST: 127.0.0.1
MYSQL_ROOT_HOST: %
MYSQL_ROOT_HOST: '%'
MYSQL_USER: root

# Specify service dependencies here if necessary
Expand All @@ -31,7 +31,7 @@ jobs:
- checkout

# specify any bash command here prefixed with `run: `
- run: mysql -u root -e "CREATE DATABASE core_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"
#- run: mysql -u root -e "CREATE DATABASE core_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"
- run: go get -u github.com/golang/lint/golint
- run: go get -u github.com/wadey/gocovmerge
- run: golint ./...
Expand Down
4 changes: 4 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package core

import (
Expand Down
11 changes: 9 additions & 2 deletions column.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package core

import (
Expand Down Expand Up @@ -41,6 +45,7 @@ type Column struct {
Comment string
}

// NewColumn creates a new column
func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column {
return &Column{
Name: name,
Expand All @@ -66,7 +71,7 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
}
}

// generate column description string according dialect
// String generate column description string according dialect
func (col *Column) String(d Dialect) string {
sql := d.QuoteStr() + col.Name + d.QuoteStr() + " "

Expand Down Expand Up @@ -94,6 +99,7 @@ func (col *Column) String(d Dialect) string {
return sql
}

// StringNoPk generate column description string according dialect without primary keys
func (col *Column) StringNoPk(d Dialect) string {
sql := d.QuoteStr() + col.Name + d.QuoteStr() + " "

Expand All @@ -114,12 +120,13 @@ func (col *Column) StringNoPk(d Dialect) string {
return sql
}

// return col's filed of struct's value
// ValueOf returns column's filed of struct's value
func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error) {
dataStruct := reflect.Indirect(reflect.ValueOf(bean))
return col.ValueOfV(&dataStruct)
}

// ValueOfV returns column's filed of struct's value accept reflevt value
func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
var fieldValue reflect.Value
fieldPath := strings.Split(col.FieldName, ".")
Expand Down
4 changes: 4 additions & 0 deletions converstion.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package core

// Conversion is an interface. A type implements Conversion will according
Expand Down
Loading

0 comments on commit f50e09f

Please sign in to comment.