Skip to content

BETWEEN fails in CASE statement #735

Closed

Description

@tmrk

I get Uncaught TypeError: Cannot read property 'toString' of undefined when I'm trying to use BETWEEN in a CASE. Other operators such as > and < still work but would be too verbose for range determination.

See fiddle: https://jsfiddle.net/h2tyvmuj/

Activity

  1. mathiasrw commented on Aug 16, 2016

    @mathiasrw
    Member

    Thanks for a perfect bugreport

  2. mathiasrw commented on Nov 19, 2025

    @mathiasrw
    Member

    Context:

    var cities = [
        {City: "Moscow", Population: 1},
        {City: "London", Population: 10},
        {City: "Paris", Population: 100}];
    
    alasql.promise('SELECT * FROM ?',[cities]).then(function(city) {
    
    	// This works
    	print(alasql('SELECT City, CASE WHEN Population > 1 AND Population < 100 THEN "yes" ELSE "no" END AS isBetween1and100 FROM ?',[city]));
      
      // This doesn't work
    	print(alasql('SELECT City, CASE WHEN Population BETWEEN 1 AND 100 THEN "yes" ELSE "no" END AS isBetween1and100 FROM ?',[city]));
    
    }).catch(function(reason) {
    	print(reason['message']);
    }).then(function() {
    	print('AlaSQL v'+alasql.version)
    });
    
    
    
    
    
    function print(x) {document.getElementById('output').textContent += JSON.stringify(x,null,'\t')+'\n';}

    becomes

    [
    	{
    		"City": "Moscow",
    		"isBetween1and100": "no"
    	},
    	{
    		"City": "London",
    		"isBetween1and100": "yes"
    	},
    	{
    		"City": "Paris",
    		"isBetween1and100": "no"
    	}
    ]
    "Cannot read properties of undefined (reading 'toString')"
    "AlaSQL v0.3.1"
    
  3. added a commit that references this issue on Nov 19, 2025
    291a762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions