Giter VIP home page Giter VIP logo

camlsql-js's Introduction

Hi there 👋

camlsql-js's People

Contributors

dlid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

camlsql-js's Issues

Normalize allowed List names

Make sure you can use proper list names where needed.
Maybe require [ ] when it contains spaces? That's a good plan!

Let's not allow spaces in a joined list alias..

SELECT * FROM ListName -> "ListName"
SELECT * FROM [List Name] -> "List Name"
SELECT * FROM List Name -> Not ok

SELECT * FROM [List Name]
JOIN FavoriteBook ON [List Name].Favourite_book 
 -> ok

SELECT * FROM [List Name]
JOIN FavoriteBook ON List Name.Favourite_book 
 -> error

SELECT * FROM [List Name]
JOIN FavoriteBook ON [List Name].Favourite_book 
 -> ok

Double groups in parsed query

vkbeautify.xml(camlsql.prepare("SELECT * FROM Movies WHERE (Title = ? AND Title LIKE ?) AND (Fun = ? OR Scary < ?)",["summer", 'did', 10, 6,0,6]).getXml());

This query creates the following parsed object.

The first two "groups" are the same. There should only be one of those.

[{
	"type": "group",
	"value": "Title = ? AND Title LIKE ?",
	"operator": "and",
	"items": [{
		"type": "statement",
		"operator": "and",
		"field": "Title",
		"macro": "@param0",
		"comparison": "eq"
	}, {
		"type": "statement",
		"operator": "and",
		"field": "Title",
		"macro": "@param1",
		"comparison": "like"
	}]
}, {
	"type": "group",
	"value": "(Title = ? AND Title LIKE ?)",
	"operator": "and",
	"items": [{
		"type": "statement",
		"operator": "and",
		"field": "(Title",
		"macro": "@param2",
		"comparison": "eq"
	}, {
		"type": "statement",
		"operator": "and",
		"field": "Title",
		"macro": "@param3",
		"comparison": "like"
	}]
}, {
	"type": "group",
	"value": "Fun = ? OR Scary < ?",
	"operator": "and",
	"items": [{
		"type": "statement",
		"operator": "and",
		"field": "Fun",
		"macro": "@param4",
		"comparison": "eq"
	}, {
		"type": "statement",
		"operator": "or",
		"field": "Scary",
		"macro": "@param5",
		"comparison": "lt"
	}]
}]

Named parameters and NULL / NOT NULL

camlsql.prepare("SELECT * FROM Listan WHERE a = @meh AND y is null", {"@meh" : "test"});

You get the error:

[camlsql] You can not mix named macros and ?

WHERE: Comparison pattern overhaul

When I write WHERE Preamble=? (with no spaces around =) then the field name is cut.

  • When using WHERE Preamble=? (with no spaces around =) then the field name is cut to <FieldRef Name="Preambl" />
  • When using Preamble<? the comparison is not recognized at all
  • When using Preamble>? the comparison becomes EQUAL and not GT
  • PreambleLIKE seems to work. But it probably should not... Same thing with Preamblein? or walkin?. Field name will be "Preamble" with an IN clause

Space madness

SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND (([Motivation] IS NULL OR [IsBoss] = ?) or P = ?) works fine

But SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND ( ([Motivation] IS NULL OR [IsBoss] = ?) or P = ?)
does not (See the SPACE character in the Motivation parenthesises.

Expanding to other CRUD operations

Greetings again! How useful do you think a library like this would be if it could expand to support the other CRUD list operations in sharepoint? I love how caml sql supports the select statement, but I think it would be a real quantum leap if it could also support inserts, updates, and deletes.

How popular/beneficial do you think that capability would be? From what I've seen, there's a few other SP JS libraries that allow you to do similar things, but their syntax is broken into something resembling LINQ methods. (I'm not asking you to develop this capability, I'm really just asking your opinion, and I would take care of the dev part myself :)

Encoded column names in result

When using encoded field names in the query it would make sense to be able to access properties using the non-encoded name in the result.

SELECT [Title], [Båtfärg] FROM ListOfBoats`

<script>
 camlsql.prepare(...).exec(function(err, rows) {

   // I want to be able to use 
   var color = rows[0]["Båtfärg"];

   // Instead of 
   var color = rows[0].B_x00e5_tf_x00e4_rg
 });
</script>

Or I will have to know the encoded filename anyway and then what's the point of being able to use the non-encoded filename in the SQL-query?

Complex queries

Complex groups will break

SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND (([Motivation] IS NULL AND [IsBoss] = ?) or (P = ? AND P2 < ?))

week start returns wrong day

getDateFromTextualRepresentation("week start", new Date(1980, 03, 04));

supposed to be 31st of april 00:00:00 but returns
Sun Mar 30 1980 00:00:00 GMT+0100 (Central Europe Standard Time)
same with week end
var d = camlsql.testonly.getDateFromTextualRepresentation("week end", new Date(1980, 03, 04));

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.