Opened 7 years ago

Closed 7 years ago

#25768 closed Uncategorized (invalid)

Cast Variable, and provide multiplication

Reported by: Ben Liyanage Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords: QuerySet.extra
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hey,

I'm trying to do an orm query and have run into two scenarios where I believe I need to use extra. The two scenarios are:

Type Casting

Casting a column to an int. Specifically, I have a boolean column that I need to do something like this:

select column::int

Multiplication

I need to multiply a column by a constant, or another column. Specifically the column from the previous cast.

select new_column * -1
select column1 * column2

Full Select Example

Ultimately I need to combine the above two like this:

select bool_column::int * -1 * another_int_column

Change History (3)

comment:1 Changed 7 years ago by Tim Graham

I think Cast is covered by #24932.

I think Django already supports multiplication in F expressions. Does that work for your case?

For future reference, please keep a ticket limited to 1 request.

comment:2 Changed 7 years ago by Ben Liyanage

Yea I actually I found most of this stuff a couple hours later. I was able to reproduce this functionality with F, Case, When, Value, and Q.

comment:3 Changed 7 years ago by Ben Liyanage

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top