Coder Social home page Coder Social logo

Comments (3)

robconery avatar robconery commented on May 19, 2024

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.

xivSolutions avatar xivSolutions commented on May 19, 2024

@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.

mzedeler avatar mzedeler commented on May 19, 2024

Thanks for the very, very fast feedback. I'm somewhat overwhelmed. I'll reply soon.

from massive-js.

Related Issues (20)

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.