Coder Social home page Coder Social logo

db's Issues

typo

in db/sqlite/collection.go

return nil, ErrQueryOffsetParam

should be

return nil, db.ErrQueryOffsetParam

db.Sort for PostgreSQL

Hi,

First of all, congrats on gosexy/db. Really nice piece of work!

Does db.Sort support other databases except MongoDB? I tried this line on a PostgreSQL database with no luck.

items := messages.FindAll(db.Sort{"timestamp": "DESC"})

Is there something I am doing wrong or is the support missing for now?

Thanks!
Jamie

Insertion to Mongodb creates "null" objectId

When I 'm trying to insert something with command collection.Append(), I get empty result id and in MongoDB occurs record with {"_id": null}, and when I'm appending some new record, I get this record with null id updated.

go version go1.3.1 linux/amd64
MongoDB shell version: 2.6.4

eliminate panics and return errors instead

It would be nice if the API like session.Collection() and other API methods would return value, err instead of throwing a panic when something goes wrong.

From http://blog.golang.org/2010/08/defer-panic-and-recover.html :

The convention in the Go libraries is that even when a package uses panic internally, its external API >still presents explicit error return values.

So it's fine if you internally use panic, but at some point it needs to return an explicit error value to the user instead of panicing.

Use new go1.1 goodies

We had ugly workarounds for the lack of reflect.MapOf and reflect.SliceOf, now that go1.1 is available we should use proper methods.

db.Item, GetDate(), and sqlite3

The date format is assumed to be this:
2006-01-02 15:04:05

but in sqlite3, the date returned is in this format:
3/9/2009 12:00:00 AM

Not sure what the solution to this is, as I can see the time stuff was commented out of your forked version of gosqlite3.

not sure if relations are working

If you run the TestRelation function, it doesn't print out what it's suppose to.

I get the following:

relations (1) []db.Item{
    db.Item{"name":"Joseph", "id":2, "place_code_id":3},
    db.Item{"place_code_id":1, "id":3, "name":"Pedro"},
    db.Item{"name":"María", "id":4, "place_code_id":0},
    db.Item{"id":5, "place_code_id":1, "name":"Roberto"},
    db.Item{"id":6, "place_code_id":2, "name":"Manuel"},
    db.Item{"place_code_id":1, "id":7, "name":"Miguel"},
}

it seems to be missing the lives_in, has_children, and has_visited. I see this in my own application as well.

Add Begin and End methods to the Database struct.

In SQL, BEGIN and END are used as transaction delimiters. PostgreSQL, SQLite3 and MySQL support this syntax, MongoDB does not, but we can add an empty method as a placeholder in the hope it gets implemented someday.

This issue is closely related to #20.

Optimize performance

gosexy/db tends to work slowly. I haven't benchmarked any results yet, but will do so as soon as possible. Right now, it appears to be one insert per second.

Using sqlite wrapper.

sqlite wrapper fails to build

It appears that the sqlite wrapper fails to build.

Error log:

wei2912@wei-lm-desktop ~/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite $ go test
# _/home/wei2912/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite
./collection.go:57: undefined: db.ErrQueryLimitParam
./collection.go:76: undefined: db.ErrQuerySortParam
./collection.go:82: undefined: ErrQueryOffsetParam
./collection.go:267: undefined: db.ErrMissingConditions
./sqlite.go:117: undefined: db.ErrNotConnected
./sqlite.go:137: undefined: db.ErrNotConnected
./sqlite.go:157: undefined: db.ErrNotConnected
./sqlite.go:195: undefined: db.ErrMissingDatabaseName
./sqlite.go:284: undefined: db.ErrCollectionDoesNotExists
FAIL    _/home/wei2912/.dropbox-files/Dropbox/Documents/GitHub/db/sqlite [build failed]

about using Database.Driver()

I'm just spit balling here, but sometimes we have to use Driver() to do complicated specialized queries. It would be nice if in those situations, we could get a db.Item. Maybe by exposing fetchRows() or making an API that calls that.

panic occurs with mysql and sqlite if sql throws error

In both the mysql and sqlite wraper, in collection.FindAll, there is code like this:

rows, _ := t.parent.doQuery(
    fmt.Sprintf("SELECT %s FROM %s", fields, t.Name()),
    fmt.Sprintf("WHERE %s", conditions), args,
    sort, limit, offset,
)

it doesn't check for an error. If doQuery throws an error (like a column not existing), then it will panic with a nil reference instead of panicing with an error that described what actually happened.

safe of Source.collections and sql driver

Excuse me, I speak English badly.
first:

We know, Maps are not safe for concurrent use.
So,maybe better for access collections of struct Source.

Second:
github.com/xiam/gosqlite3
github.com/xiam/gopostgresql
not synchronization with original package.
Original package has been updated to improve a lot.
Is not possible to use the original package.

Also
Expect to solve #12 soon as possible

querying database doesn't always convert the type correctly.

I ran into an interesting problem while testing my application with postgresql and mongodb. Part of the application finds rows within a certain date range. While this works in mongodb just fine, it doesn't work in postgresql.

This works in mongodb:

res, err := cp.Query(
  db.And{
    db.Cond{"date >=": dateFrom},
    db.Cond{"date <=": dateTo},
  },
)

and this makes it work in postgresql:

res, err := cp.Query(
  db.And{
    db.Cond{"date >=": dateFrom.Format("2006-01-02 15:04:05")},
    db.Cond{"date <=": dateTo.Format("2006-01-02 15:04:05")},
  },
)

Because in the postgresql example, inside the compileStatement() function it just uses to.String() to convert the values. Would it be possible that this instead uses toInternal()? Because that function will format the date correctly.

query matching, "like"

Is there a way to do "like" matching without doing raw SQL? E.g. "select * from table where column like "%something%".

If there isn't, maybe there needs to be a new db.Cond or maybe if it detects a %, it can do a LIKE automatically. Let me know your thoughts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.