Common SQL Errors

MySQL Error 3154: ER_JSON_BAD_ONE_OR_ALL_ARG - How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL JSON functions received an invalid oneOrAll argument; only 'one' or 'all' are allowed.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is Error Code 3154 (ER_JSON_BAD_ONE_OR_ALL_ARG)?

ER_JSON_BAD_ONE_OR_ALL_ARG occurs when a MySQL JSON function gets an invalid oneOrAll argument. Use the exact string 'one' or 'all' to resolve the error.

Error Highlights

Typical Error Message

ER_JSON_BAD_ONE_OR_ALL_ARG

Error Type

Syntax Error

Language

MySQL

Symbol

or 'all'. ER_JSON_BAD_ONE_OR_ALL_ARG was added in 5.7.8.

Error Code

3154

SQL State

42000

Explanation

Table of Contents

What is Error Code 3154 (ER_JSON_BAD_ONE_OR_ALL_ARG)?

MySQL error code 3154, condition ER_JSON_BAD_ONE_OR_ALL_ARG, appears when a JSON function receives an invalid oneOrAll argument.

The argument must be the literal string 'one' or 'all'; any other value triggers the 42000 SQL state and stops query execution.

What Causes This Error?

Most cases involve typos, extra spaces, or a variable that evaluates to something other than 'one' or 'all'.

Older client libraries or ORM code that builds dynamic SQL may also supply numeric or NULL values, causing the check added in MySQL 5.7.8 to fail.

How to Fix ER_JSON_BAD_ONE_OR_ALL_ARG

Confirm the second argument of functions like JSON_CONTAINS_PATH, JSON_SEARCH, and JSON_REMOVE is hard coded as 'one' or 'all'.

If you need to drive the value dynamically, validate input in application code or with a CASE expression before calling the JSON function.

Common Scenarios and Solutions

JSON_CONTAINS_PATH(JSON_OBJECT('a',1,'b',2), 'any', '$.a') fails because 'any' is not accepted.

A stored procedure that passes a user parameter directly can fail when the user enters blank text; coalesce it to 'one' or 'all' first.

Best Practices to Avoid This Error

Always use lowercase constants 'one' and 'all', and wrap them in single quotes to avoid ambiguity.

Galaxy's editor linting flags invalid literals in JSON functions early, reducing runtime errors in staging and production.

Related Errors and Solutions

Error 3145 ER_JSON_VALUE_OUT_OF_RANGE arises when JSON numbers exceed the range of DOUBLE.

Error 3146 ER_INVALID_JSON_TEXT means the supplied string is not valid JSON; both can occur alongside 3154 during complex imports.

Common Causes

Common Causes

Spelling the parameter as ONE, One, or any other value instead of lowercase 'one'.

Passing a bind variable that contains an empty string or NULL.

Using a client older than 5.7.8 that interprets the enumeration differently.

Related Errors

ER_INVALID_JSON_TEXT (3146)

Occurs when the supplied string is not valid JSON; often appears during bulk imports.

ER_JSON_VALUE_OUT_OF_RANGE (3145)

Raised when a JSON numeric value exceeds the allowed range for DOUBLE.

ER_INVALID_TYPE_FOR_JSON (3144)

Signals that a non-JSON-compatible type was supplied to a JSON function.

FAQs

Is the oneOrAll argument case sensitive?

No. MySQL treats 'ONE' and 'one' the same, but using lowercase avoids confusion.

Can I pass a column name instead of a literal?

Yes, but first ensure the column value is either 'one' or 'all' to avoid runtime errors.

Does this error occur in MariaDB?

No. The specific check and error code are unique to MySQL 5.7.8 and later.

How does Galaxy help?

Galaxy's SQL linter flags invalid oneOrAll values while you type, preventing the error before execution.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo