Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #76 from dadleyy/GH-75/count-fix
Browse files Browse the repository at this point in the history
correcting postgres placeholder indexed param calculations
  • Loading branch information
dadleyy authored Dec 11, 2017
2 parents 45af02c + 1e40d5d commit 95686b3
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 207 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ script:
- make
- make test
- make test-example
- go run marlowc/main.go -input examples/library/models -stdout=true
- make example
- pushd ./examples/library && ./library && popd
after_success:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ LIBRARY_EXAMPLE_COVERAGE_REPORT=$(LIBRARY_COVERAGE_OUTPUT_DIR)/library.coverage.
LIBRARY_EXAMPLE_COVERAGE_DISTRIBUTABLE=$(LIBRARY_COVERAGE_OUTPUT_DIR)/library.coverage.html
LIBRARY_EXAMPLE_TEST_FLAGS=-covermode=atomic $(TEST_VERBOSITY) -coverprofile=$(LIBRARY_EXAMPLE_COVERAGE_REPORT)

.PHONY: all lint test test-example clean clean-example

all: $(EXE)

$(EXE): $(VENDOR_DIR) $(GO_SRC) $(LIB_SRC)
Expand All @@ -78,7 +80,9 @@ $(VENDOR_DIR):
$(GO) get -v -u github.com/golang/lint/golint
$(GLIDE) install

example: $(LIBRARY_EXAMPLE_SRC) $(LIBRARY_EXAMPLE_MAIN) $(EXE)
example: $(LIBRARY_EXAMPLE_EXE)

$(LIBRARY_EXAMPLE_EXE): $(LIBRARY_EXAMPLE_SRC) $(LIBRARY_EXAMPLE_MAIN) $(EXE)
$(GO) get -v github.com/lib/pq
$(GO) get -v github.com/mattn/go-sqlite3
$(GO) install -v -x github.com/mattn/go-sqlite3
Expand Down
7 changes: 0 additions & 7 deletions examples/library/data/genres.sql

This file was deleted.

15 changes: 15 additions & 0 deletions examples/library/data/postgres.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
drop table if exists genres;

create table genres (
id SERIAL,
name TEXT,
parent_id INTEGER
);

drop table if exists multi_auto;

create table multi_auto (
id SERIAL,
status TEXT DEFAULT 'pending' NOT NULL,
name TEXT
);
16 changes: 14 additions & 2 deletions examples/library/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import "os"
import "log"
import "fmt"
import "bytes"
import _ "github.com/mattn/go-sqlite3"
import "database/sql"
import "github.com/dadleyy/marlow/examples/library/data"
Expand Down Expand Up @@ -110,7 +111,9 @@ func main() {
NameLike: []string{"danny"},
})

authorStore := models.NewAuthorStore(db)
queryLog := new(bytes.Buffer)

authorStore := models.NewAuthorStore(db, queryLog)

a, e := authorStore.FindAuthors(&models.AuthorBlueprint{
ID: []int{1, 2, 3},
Expand All @@ -124,7 +127,16 @@ func main() {
log.Printf("found author name[%s]", author.Name)
}

bookStore := models.NewBookStore(db)
queryLog.Reset()

bookStore := models.NewBookStore(db, queryLog)

if _, e := bookStore.CreateBooks(models.Book{Title: "AwesomeBook"}); e != nil {
log.Fatalf("unable to create book: %v", e)
}

log.Printf("%v", queryLog.String())

b, e := bookStore.FindBooks(&models.BookBlueprint{
ID: []int{1, 2},
})
Expand Down
6 changes: 5 additions & 1 deletion examples/library/models/author_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package models

import "os"
import "io"
import "fmt"
import "bytes"
import "strings"
import "testing"
import _ "github.com/mattn/go-sqlite3"
Expand Down Expand Up @@ -37,6 +39,7 @@ func Test_Author(t *testing.T) {
g := goblin.Goblin(t)
var db *sql.DB
var store AuthorStore
var queryLog io.Writer

dbFile := "author-testing.db"
generatedAuthorCount := 150
Expand Down Expand Up @@ -149,7 +152,8 @@ func Test_Author(t *testing.T) {
})

g.BeforeEach(func() {
store = NewAuthorStore(db)
queryLog = new(bytes.Buffer)
store = NewAuthorStore(db, queryLog)
})

g.After(func() {
Expand Down
6 changes: 5 additions & 1 deletion examples/library/models/book_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package models

import "os"
import "io"
import "fmt"
import "bytes"
import "strings"
import "testing"
import _ "github.com/mattn/go-sqlite3"
Expand Down Expand Up @@ -35,6 +37,7 @@ func addBookRow(db *sql.DB, values ...[]string) error {
func Test_Book(t *testing.T) {
var db *sql.DB
var store BookStore
var queryLog io.Writer

g := goblin.Goblin(t)
testBookCount := 150
Expand Down Expand Up @@ -77,7 +80,8 @@ func Test_Book(t *testing.T) {
})

g.BeforeEach(func() {
store = NewBookStore(db)
queryLog = new(bytes.Buffer)
store = NewBookStore(db, queryLog)
})

g.After(func() {
Expand Down
Loading

0 comments on commit 95686b3

Please sign in to comment.