AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.01k stars 653 forks source link

Salesforce Locker Service #1017

Closed KyooMario closed 6 years ago

KyooMario commented 6 years ago

Hello Team,

We are using your solution with great pleasure within Salesforce (and Sharepoint) scripting. Till the latest version release of Salesforce everything was working fine but since a week (summer 18 release) we get an error. (Actually no error but it just stops working)

Now Salesforce has introduced the Locker Service which seems to cause the issue: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_code.htm

When we set the working version back to "before" Locker Service everything works as expected.

Question: Do you recognize what is causing the issue code wise and can you fix this?

Kind regards, Mario

mathiasrw commented 6 years ago

Hi Mario

Thanks for reaching out. I feel convinced that the demand for use strict is the main reason it's not running anymore.

We should look into this. Im a bit worried about the autogenerated code for the JISON parser but hopefully it turns out ok.

If we manage to get this going, would you be interested in writing an article describing how/why you use AlaSQL in your salesforce setup?

KyooMario commented 6 years ago

Hello Mathias,

Thanks. And of course.

Kind regards, Mario

mathiasrw commented 6 years ago

Are you using SQL triggers?

(Have managed to implement use strict but having a nasty bug related to triggers. If you dont use them we can make a special version for you to test if it solves the issue.)

KyooMario commented 6 years ago

Hello Mathias,

No. I don’t use them. ( I wasn’t aware we have them πŸ˜‰)

Kind regards, Mario

mathiasrw commented 6 years ago

The latest release 0.4.6 is now in strict mode (and all bugs identified by the regression test are fixed)

Would it be possible for you to check if the last version of AlaSQL is working in your salesforce setup?

KyooMario commented 6 years ago

Hello Mathias,

I get the following error message:

[Cannot read property 'indexedDB' of undefined] eval()@https://kyooact-dev-ed.lightning.force.com/resource/1529050604000/kyooact__Kyoo/alasql.js:3435:24 eval()@https://kyooact-dev-ed.lightning.force.com/resource/1529050604000/kyooact__Kyoo/alasql.js:3436:3 eval()@https://kyooact-dev-ed.lightning.force.com/resource/1529050604000/kyooact__Kyoo/alasql.js:59:23 Proxy.eval()@https://kyooact-dev-ed.lightning.force.com/resource/1529050604000/kyooact__Kyoo/alasql.js:61:2

Kind regards, Mario

mathiasrw commented 6 years ago

Hmmmm.

Any chance you can share the SQL running for me to get some leads?

KyooMario commented 6 years ago

Hello Matthias,

Give me a few days and I will set something up.

Kind regards, Mario

Sent from my iPhone

On 17 Jun 2018, at 13:47, Mathias Rangel Wulff notifications@github.com<mailto:notifications@github.com> wrote:

Hmmmm.

Any chance you can share the SQL running for me to get some leads?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agershun/alasql/issues/1017#issuecomment-397873397, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlK5Xm_kBcMSm89raNAVzGju_UZr-tQWks5t9kHegaJpZM4UmXWb.

KyooMario commented 6 years ago

Hello Mathias,

I have setup a Salesforce Dev Org: Url: https://alasql-dev-ed.lightning.force.com Login: alasql@kyoo.studiomailto:alasql@kyoo.studio PW: L%j1LS5X

The Salesforce page where we call the alasql function: https://alasql-dev-ed.lightning.force.com/lightning/n/ALASQL You get a popup with the error message.

The alasql and jquery are included in a resource zip which we call on the above page. You can upload an updated zip here: https://alasql-dev-ed.lightning.force.com/lightning/setup/StaticResources/home After this just refresh the above page and you can see the updated error message.

If you have any questions please let me know. OK?

Hope you can resolve.

Kind regards, Mario

mathiasrw commented 6 years ago

Cool. Ill have a look at it in the weekend.

mathiasrw commented 6 years ago

You're trying to Log In to Salesforce. To make sure your Salesforce account is secure, we have to verify your identity. Enter the verification code we emailed to ma*@oo.studio. Verification Code

mathiasrw commented 6 years ago

Can you help me login? You might want to change the email to m@rawu.dk so I can do the verification thing myself?

KyooMario commented 6 years ago

Hello Mathias,

I have changed the email address to m@rawu.dkmailto:m@rawu.dk

Kind regards, Mario

mathiasrw commented 6 years ago

Perfect. I will look into this in the weekend.

mathiasrw commented 6 years ago

With the latest changes no error is displayed - but I see no output on the https://alasql-dev-ed.lightning.force.com/lightning/n/ALASQL page.

Is it meant to provide any output after alasqlResult =?

KyooMario commented 6 years ago

Hello Mathias,

The Static Resource must also include β€œjquery.min.js” </ltng:require>

You left it out? And now I included it again: With the correct result πŸ˜‰ Good Job !!

The code used is: var source = [{"Title":"Item 01"},{"Title":"Item 02"}] var result = alasql('SELECT * FROM ? ', [source]); console.log('result: '+result); component.set('v.alasqlResult', JSON.stringify(result));

You can see the result on the page now πŸ˜‰

Just in case: If you want to code yourselves you can do this as follows:

  1. Open the Developer Console: [cid:image003.jpg@01D41B09.EC7F0530]

  2. Open the ALASQL Component: [cid:image005.jpg@01D41B09.EC7F0530]

  3. You can open the Component (page) and the Controller (script) The code is not hard to read.

If questions please ask.

Thanks so far.

Kind regards, Mario

From: Mathias Rangel Wulff notifications@github.com Sent: Saturday, 14 July 2018 00:09 To: agershun/alasql alasql@noreply.github.com Cc: Mario Kyoo mario@kyoo.studio; Author author@noreply.github.com Subject: Re: [agershun/alasql] Salesforce Locker Service (#1017)

With the latest changes no error is displayed - but I see no output on the alasql-dev-ed.lightning.force.com/lightning/n/ALASQL page.

Is it meant to provide any output after alasqlResult =?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agershun/alasql/issues/1017#issuecomment-404966268, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlK5XhjLOF48s3pE2FOtOohZyiU3r_Csks5uGRp9gaJpZM4UmXWb.

mathiasrw commented 6 years ago

Perfect!

The updated version is now deployed as version 0.4.7.

I would love to play around a bit if you could let the link be open a week or so more :)

KyooMario commented 6 years ago

Hello Mathias,

Great. Thanks a lot. Take as long as you want. There are no cost involved.

Kind regards, Mario

KyooMario commented 6 years ago

Hello Mathias or Andrey,

I have constructed the following statement: alasql.fn.writeButton = function(name) { return '{"buttonAction":"addTab","buttonValue":"'+name+'"}'; } result = alasql('SELECT Title, {label:Form,[value]:writeButton(CONCAT("{\"label\":\"",Title,"\",\"value\":\"",Title,"\"}")),[action]:"{!c.buttonAction}"} AS [Form] FROM ?', [result]);

it returns: [{"Title":"Kyoo Demo Form","Form":{"value":"{\"buttonAction\":\"addTab\",\"buttonValue\":\"{\"label\":\"Kyoo Demo Form\",\"value\":\"Kyoo Demo Form\"}\"}","action":"{!c.buttonAction}"}},{"Title":"test","Form":{"value":"{\"buttonAction\":\"addTab\",\"buttonValue\":\"{\"label\":\"test\",\"value\":\"test\"}\"}","action":"{!c.buttonAction}"}}]

As you can see we end up with a \” in the object where we need only the β€œ.

But if we only use \” instead of \” alasql returns an error.

Can you advise how to fix this?

Kind regards, Mario

From: Mario Kyoo Sent: Saturday, 14 July 2018 21:45 To: agershun/alasql reply@reply.github.com Cc: agershun/alasql alasql@noreply.github.com; Author author@noreply.github.com Subject: Re: [agershun/alasql] Salesforce Locker Service (#1017)

Hello Mathias,

Great. Thanks a lot. Take as long as you want. There are no cost involved.

Kind regards, Mario Sent from my iPhone

On 14 Jul 2018, at 21:02, Mathias Rangel Wulff notifications@github.com<mailto:notifications@github.com> wrote:

Perfect!

The updated version is now deployed as version 0.4.7.

I would love to play around a bit if you could let the link be open a week or so more :)

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agershun/alasql/issues/1017#issuecomment-405043297, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlK5XtUlgGAokg39mn-jAb7_DKviqsurks5uGkBGgaJpZM4UmXWb.

KyooMario commented 6 years ago

Hello Mathias,

Playing a bit I think I should do it as follows: result = alasql('SELECT Title, ({"label":"Form","value":{"label":Title,"value":Title},"action":"{!c.buttonAction}"}) AS [Form] FROM ?', [result]);

Kind regards, Mario

From: Mario Kyoo Sent: Saturday, 15 September 2018 19:54 To: agershun/alasql reply@reply.github.com Cc: agershun/alasql alasql@noreply.github.com; Author author@noreply.github.com Subject: Escape double quote in select statement

Hello Mathias or Andrey,

I have constructed the following statement: alasql.fn.writeButton = function(name) { return '{"buttonAction":"addTab","buttonValue":"'+name+'"}'; } result = alasql('SELECT Title, {label:Form,[value]:writeButton(CONCAT("{\"label\":\"",Title,"\",\"value\":\"",Title,"\"}")),[action]:"{!c.buttonAction}"} AS [Form] FROM ?', [result]);

it returns: [{"Title":"Kyoo Demo Form","Form":{"value":"{\"buttonAction\":\"addTab\",\"buttonValue\":\"{\"label\":\"Kyoo Demo Form\",\"value\":\"Kyoo Demo Form\"}\"}","action":"{!c.buttonAction}"}},{"Title":"test","Form":{"value":"{\"buttonAction\":\"addTab\",\"buttonValue\":\"{\"label\":\"test\",\"value\":\"test\"}\"}","action":"{!c.buttonAction}"}}]

As you can see we end up with a \” in the object where we need only the β€œ.

But if we only use \” instead of \” alasql returns an error.

Can you advise how to fix this?

Kind regards, Mario

From: Mario Kyoo Sent: Saturday, 14 July 2018 21:45 To: agershun/alasql reply@reply.github.com Cc: agershun/alasql alasql@noreply.github.com<mailto:alasql@noreply.github.com>; Author author@noreply.github.com<mailto:author@noreply.github.com> Subject: Re: [agershun/alasql] Salesforce Locker Service (#1017)

Hello Mathias,

Great. Thanks a lot. Take as long as you want. There are no cost involved.

Kind regards, Mario Sent from my iPhone

On 14 Jul 2018, at 21:02, Mathias Rangel Wulff notifications@github.com<mailto:notifications@github.com> wrote:

Perfect!

The updated version is now deployed as version 0.4.7.

I would love to play around a bit if you could let the link be open a week or so more :)

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agershun/alasql/issues/1017#issuecomment-405043297, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlK5XtUlgGAokg39mn-jAb7_DKviqsurks5uGkBGgaJpZM4UmXWb.

mathiasrw commented 6 years ago

So, did you manage to solve it?

KyooMario commented 6 years ago

Hello Mathias,

Yes. Thanks. Actually it was quite easy. Could not find documentation about it though so it took a while with trial and error to learn.

Thanks for following up this fast.

Kind regards Mario

Sent from my iPhone

On 16 Sep 2018, at 09:30, Mathias Rangel Wulff notifications@github.com<mailto:notifications@github.com> wrote:

So, did you manage to solve it?

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/agershun/alasql/issues/1017#issuecomment-421715993, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlK5XsZmJ2nJTEjzN73MhcVbj0GhoVIfks5ubf4qgaJpZM4UmXWb.