Git Product home page Git Product logo

gql's People

Contributors

calvinmetcalf avatar dsharer avatar marfarma avatar pangratz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gql's Issues

working example with inline javascript

i am trying to use GQL plugin using inline javascript in a html file
but i am keep on getting this error "Uncaught TypeError: undefined is not a function "
can you please post a working example for GQL plugin

many thanks

aggregates with groupBy never returns

The following test (from my pull request #4), when not commented out, fails. The query never returns, and the test times out. Disabled the timeout and waited several minutes - it still didn't return.

+    /* ------------ test is failing - never returns ------------- */
 +    // it("should return count aggregation for group by clause", function(done) {
 +    //     //this.timeout(0);
 +    //     var query = {select: "average(salary), isSenior", groupBy: "isSenior"};
 +    //   //var query = "select lunchTime, count(age) group by isSenior";
 +    //   var expected = [{"lunchTime": "12:00:00", "count-age": "2"}, 
 +    //                  {"lunchTime": "13:00:00", "count-age": "1"}, 
 +    //                  {"lunchTime": "12:00:00", "count-age": "2"}]; 
 +    //    
 +    //   PouchDB.plugin('gql', GQL);
 +    //   PouchDB('testdb',function(err,db){
 +    //       db.gql(query, function(err, actual){
 +    //         if(!err){
 +    //             var intersection = expected.filter(function(n) {
 +    //               return _.findWhere(actual.rows, n) != undefined
 +    //             });
 +    //             console.log(" ");
 +    //             for (var i=0; i< actual.rows.length; i++) {
 +    //                 console.log(actual.rows[i]);
 +    //             }
 +    //             expect(intersection).to.have.length(expected.length);
 +    //             expect(actual.rows.length).to.equal(expected.length);
 +    //             done();            
 +    //         } 
 +    //       });
 +    //   });   
 +    // });

Only lower case properties work

PouchDB seems to be fine with case sensitivity but GQL apparently only works with lower case properties.

This seems to come down to the handleDelimitedCharacters function which performs a toLowerCase on the query input.

I don't see the benefit of performing the lower case transformation and think it should be removed.

up coverage

running npm test --coverage we are at

================== Coverage summary ==================
Statements   : 53.61% ( 267/498 )
Branches     : 36.84% ( 98/266 )
Functions    : 48.84% ( 63/129 )
Lines        : 53.61% ( 267/498 )
====================================================

Update for persisted map/reduce

Would be nice if this worked with persisted map/reduce. Not sure what the GQL interface for working with indexes looks like, but it would be a great performance boost compared to using the changes() API.

Aggregate select statement not working

Aggregate select test fails (reference file test/test.js for full context, this test is there but commented out). Error differs depending on the group-by column.

  • Group by name (which is distinct, so the aggregation is a no-op) and the error is 'Uncaught.'
  • Group by isSenior and the error message, 'Error: If an aggregation function is used in the select clause, all identifiers in the select clause must be wrapped by an aggregation function or appear in the group-by clause.' is invalid relative to the actual query.

    it("should return average aggregation for group by clause", function(done) {
        
      //var query = {select: "name, average(salary)", groupBy: "name"}; //- error is 'Uncaught'
      var query = {select: "isSenior, average(salary)", groupBy: "isSenior"}; 
     //- error is 'Error: If an aggregation function is used in the select clause, all identifiers in the select clause must be wrapped by an aggregation function or appear in the group-by clause.'
        var expected = [{"isSenior": true, "average-salary": "2"}, 
                     {"isSenior": false, "average-salary": "1"}]; 
       
        PouchDB.plugin('gql', GQL);
        PouchDB('testdb',function(err,db){
            db.gql(query, function(err, actual){
              if(!err){
                  var intersection = expected.filter(function(n) {
                    return _.findWhere(actual.rows, n) != undefined
                  });
                  console.log(' ');
                  for (var i=0; i< actual.rows.length; i++) {
                      console.log(actual.rows[i]);
                  }
                  expect(intersection).to.have.length(expected.length);
                  expect(actual.rows.length).to.equal(expected.length);
                  done();            
              } else {
                  console.log(err);
                  done(new Error(err.reason));
              }
            });
        });   
      });

Getting 'db.gql is not a function'

Im building an android app with cordova, and after installing GQL plugin using 'bower install pouchdb-gql' and then including the 'dist/pouchdb.gql.js' in the head of my index, I am getting the error 'db.gql is not a function' when I try to execute a query.

Anyone know what is wrong? Is this plugin still maintained?

Edit: Seen last commit mid 2014. This plugin should be reviewed

cleaning: more deduping/bringing out of clousures

there is some room to bring more functions that don't require closures out of the body of other functions, and also some stuff is repeated (operators at first glance) this stuff can be deduped, possibly into their own file.

tests/clean up

we need to add tests, wrap it in a umd, and make it available at least via npm

Add a warning to the readme about performance

It's not clear from the docs that this has to loop through all the documents in memory. I know it was written at a time when persisted map/reduce didn't exist and so it didn't have the option, but I think people are stumbling across it and not understanding the performance costs.

select columns where value contains colons returned as null

The following test, from my pull request (see #4). when not commented out, fails. The value of the 'lunchTime' property is null in each returned row. This is not the case when selecting all columns, i.e. select '*'

I suspect it's related to the embedded colons, but it may be that it's attempting to parse the values as number and failing.

 
/* ------------ test is failing - lunchTime column is returned as null ------------- */
 +    // it("should return selected columns when one column is a time representation", function(done) {
 +    //   var query = {select: "lunchTime, name"};
 +    //   var expected = [{"lunchTime": "12:00:00", "name": "John"}, 
 +    //                  {"lunchTime": "12:00:00", "name": "Dave"}, 
 +    //                  {"lunchTime": "13:00:00", "name": "Sally"}, 
 +    //                  {"lunchTime": "12:00:00", "name": "Ben"}, 
 +    //                  {"lunchTime": "12:00:00", "name": "Dana"}, 
 +    //                  {"lunchTime": "13:00:00", "name": "Mike"}];
 +    //   
 +    //   PouchDB.plugin('gql', GQL);
 +    //   PouchDB('testdb',function(err,db){
 +    //       db.gql(query, function(err, actual){
 +    //         if(!err){
 +    //             var intersection = expected.filter(function(n) {
 +    //               return _.findWhere(actual.rows, n) != undefined
 +    //             });
 +    //             console.log(" ");
 +    //             for (var i=0; i< actual.rows.length; i++) {
 +    //                 console.log(actual.rows[i]);
 +    //             }
 +    //             expect(intersection).to.have.length(expected.length);
 +    //             expect(actual.rows.length).to.equal(expected.length);
 +    //             done();            
 +    //         } else {
 +    //           done(err);
 +    //         }
 +    //       });
 +    //   });   
 +    // });

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.