Skip to content

Parameter with_namespace in _set_sql is always False #675

Open
@cattybaby723

Description

@cattybaby723

In readme of updating data shows

The syntax for joining tables is the same as when selecting data

customers, profiles = Tables('customers', 'profiles')

Query.update(customers)
     .join(profiles).on(profiles.customer_id == customers.id)
     .set(customers.lname, profiles.lname)
UPDATE "customers"
JOIN "profiles" ON "profiles"."customer_id"="customers"."id"
SET "customers"."lname"="profiles"."lname"

But actually I got

UPDATE `customers` 
JOIN `profiles` ON `profiles`.`customer_id`=`customers`.`id` 
SET `lname`=`profiles`.`lname`

And I found parameter "with_namespace" was set to "False" in _set_sql() forcibly

# In pypika/queries.py at line 1527
    def _set_sql(self, **kwargs: Any) -> str:
        return " SET {set}".format(
            set=",".join(
                "{field}={value}".format(
                    field=field.get_sql(**dict(kwargs, with_namespace=False)), value=value.get_sql(**kwargs)
                )
                for field, value in self._updates
            )
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions