Comments (3)
Let me see if I understand the problem(s): the first is that you overrode a generated routine and want Massive to stop you from doing that. The problem is Javascript doesn't have a facility for that - there's no way for Massive to know that you've done such a thing.
The second seems to be that you encountered a problem running your query - meaning that your SQL string has two parameters ($1
and $2
) but you only passed one parameter, so it didn't work.
Did I get this right?
If so, what would you expect Massive to do in each case?
from massive-js.
@mzedeler - It's hard to know exactly what's happening beyond the obvious here. The obvious is that your override of the generated insert()
method attempts to perform an insert with a mismatch between expected parameter values, and actual parameter values.
One of the handy things about JavaScript is that is allows you to bolt on new methods/properties ("overrides") etc.. to your heart's content, and will try to do what you tell it to.
One of the challenges of Javascript is that it will allow you to bolt on new methods/properties ("overrides") etc. and will try to do what you tell it to without complaining.
In this case, it is doing almost exactly what you are asking - you added an override (intentionally or no) for an existing method which appears to build either a flawed SQL statement, or incorrectly matches parameter values to parameters specified. Massive attempts to execute, and Postgres itself complains to the PG library, which passes the error on up to Massive.
In any other language, (say, a strongly typed language such as C#) it is possible to create an override method which compiles, and executes without complaint from the compiler or runtime, and which still fails when it attempts to execute improperly constructed SQL against PG or any other database.
It doesn't matter if the method is an override or not, it still needs to pass to the backing store a SQL statement with a matching set of params and values. If the parameter values don't match the parameters specified, you will get a similar error.
Unless I am missing something, the problem is not that Massive allowed an "override" but that there is a bug in the code in the "override" method itself? There is no way Massive, or any other library, can protect you from attempting to execute SQL with a mis-match between parameter placeholders and parameter values beyond doing precisely what happened here.
In other words, are you asking massive to warn you if a method in your own code attempts to override an existing method? Or are you asking massive to check what your override method does to make sure it is going to work correctly? The former is probably doable (though not practical, nor really necessary), the latter is not. If you choose to override a method, you do then need to make the code work properly.
Have we missed something?
from massive-js.
Thanks for the very, very fast feedback. I'm somewhat overwhelmed. I'll reply soon.
from massive-js.
Related Issues (20)
- Read replicas connections from Massive HOT 6
- Options fields does not work for insert HOT 4
- How do I add coordinate Document Tables creation with my migration tool? HOT 3
- Save to a table with column type jsonb[] HOT 16
- (node:533) UnhandledPromiseRejectionWarning: RangeError: Variable $1 out of range. Parameters array length: 0 HOT 3
- framework example for express.js HOT 10
- LIKE comparison on array using ANY() HOT 2
- Update body (jsonb) and field at once HOT 3
- Create type as enum HOT 2
- Issues with $ placeholds in QueryFiles, pg-promise HOT 6
- Better way to decompose using postgres HOT 1
- Transactions - getting error using async/await HOT 1
- Transaction that does insert and uses the id from that insert for next insert in transaction HOT 13
- Massive.js is not working with auto-increment fields HOT 4
- Document query generated includes >= operation HOT 2
- Problem successfully persisting or querying data, despite db.listTables() functioning correctly HOT 2
- Incompatibility with pg-promise event receive (with camel casing) HOT 13
- Does not work with Oracle?? HOT 2
- Question: Named Parameter Syntax HOT 2
- Database.prototype.clone performance bottleneck HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from massive-js.