def depopulate(self, is_update):
fields = {}<EOL>schema = self.schema<EOL>for k, field in schema.fields.items():<EOL><INDENT>is_modified = k in self.modified_fields<EOL>orig_v = getattr(self, k)<EOL>v = field.iset(<EOL>self,<EOL>orig_v,<EOL>is_update=is_update,<EOL>is_modified=is_modified<EOL>)<EOL>if is_modified or v is not None:<EOL><INDENT>if is_update and field.is_pk() and v == orig_v:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>fields[k] = v<EOL><DEDENT><DEDENT><DEDENT>if not is_update:<EOL><INDENT>for field_name in schema.required_fields.keys():<EOL><INDENT>if field_name not in fields:<EOL><INDENT>raise KeyError("<STR_LIT>".format(field_name))<EOL><DEDENT><DEDENT><DEDENT>return fields<EOL>
Get all the fields that need to be saved

        :param is_udpate: bool, True if update query, False if insert
        :returns: dict, key is field_name and val is the field value to be saved