From cca0a3f76d34f6ae1ffdb84fae42ca7950dc0720 Mon Sep 17 00:00:00 2001 From: Zheng Yang Date: Mon, 8 Sep 2014 18:31:32 +0800 Subject: [PATCH] name correction: QueryBuilder instead of QueryWriter --- orm/qb.go | 20 ++++++++++---------- orm/qb_mysql.go | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/orm/qb.go b/orm/qb.go index c85902b3..6822259a 100644 --- a/orm/qb.go +++ b/orm/qb.go @@ -17,16 +17,16 @@ package orm import "errors" type QueryBuilder interface { - Select(fields ...string) QueryWriter - From(tables ...string) QueryWriter - Where(cond string) QueryWriter - LimitOffset(limit int, offset int) QueryWriter - InnerJoin(table string) QueryWriter - LeftJoin(table string) QueryWriter - On(cond string) QueryWriter - And(cond string) QueryWriter - Or(cond string) QueryWriter - In(vals ...string) QueryWriter + Select(fields ...string) QueryBuilder + From(tables ...string) QueryBuilder + Where(cond string) QueryBuilder + LimitOffset(limit int, offset int) QueryBuilder + InnerJoin(table string) QueryBuilder + LeftJoin(table string) QueryBuilder + On(cond string) QueryBuilder + And(cond string) QueryBuilder + Or(cond string) QueryBuilder + In(vals ...string) QueryBuilder Subquery(query string, rename string) string String() string } diff --git a/orm/qb_mysql.go b/orm/qb_mysql.go index 1dadda2b..4aa3f88c 100644 --- a/orm/qb_mysql.go +++ b/orm/qb_mysql.go @@ -23,54 +23,54 @@ type MySQLQueryBuilder struct { QueryString []string } -func (qw *MySQLQueryBuilder) Select(fields ...string) QueryWriter { +func (qw *MySQLQueryBuilder) Select(fields ...string) QueryBuilder { segment := fmt.Sprintf("SELECT %s", strings.Join(fields, ", ")) qw.QueryString = append(qw.QueryString, segment) return qw } -func (qw *MySQLQueryBuilder) From(tables ...string) QueryWriter { +func (qw *MySQLQueryBuilder) From(tables ...string) QueryBuilder { segment := fmt.Sprintf("FROM %s", strings.Join(tables, ", ")) qw.QueryString = append(qw.QueryString, segment) return qw } -func (qw *MySQLQueryBuilder) Where(cond string) QueryWriter { +func (qw *MySQLQueryBuilder) Where(cond string) QueryBuilder { qw.QueryString = append(qw.QueryString, "WHERE "+cond) return qw } -func (qw *MySQLQueryBuilder) LimitOffset(limit int, offset int) QueryWriter { +func (qw *MySQLQueryBuilder) LimitOffset(limit int, offset int) QueryBuilder { qw.QueryString = append(qw.QueryString, fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset)) return qw } -func (qw *MySQLQueryBuilder) InnerJoin(table string) QueryWriter { +func (qw *MySQLQueryBuilder) InnerJoin(table string) QueryBuilder { qw.QueryString = append(qw.QueryString, "INNER JOIN "+table) return qw } -func (qw *MySQLQueryBuilder) LeftJoin(table string) QueryWriter { +func (qw *MySQLQueryBuilder) LeftJoin(table string) QueryBuilder { qw.QueryString = append(qw.QueryString, "LEFT JOIN "+table) return qw } -func (qw *MySQLQueryBuilder) On(cond string) QueryWriter { +func (qw *MySQLQueryBuilder) On(cond string) QueryBuilder { qw.QueryString = append(qw.QueryString, "ON "+cond) return qw } -func (qw *MySQLQueryBuilder) And(cond string) QueryWriter { +func (qw *MySQLQueryBuilder) And(cond string) QueryBuilder { qw.QueryString = append(qw.QueryString, "AND "+cond) return qw } -func (qw *MySQLQueryBuilder) Or(cond string) QueryWriter { +func (qw *MySQLQueryBuilder) Or(cond string) QueryBuilder { qw.QueryString = append(qw.QueryString, "OR "+cond) return qw } -func (qw *MySQLQueryBuilder) In(vals ...string) QueryWriter { +func (qw *MySQLQueryBuilder) In(vals ...string) QueryBuilder { segment := fmt.Sprintf("IN (%s)", strings.Join(vals, ", ")) qw.QueryString = append(qw.QueryString, segment) return qw