All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.odysz.transact.sql.parts.update.SetList Maven / Gradle / Ivy

package io.odysz.transact.sql.parts.update;

import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.odysz.semantics.ISemantext;
import io.odysz.transact.sql.parts.AbsPart;
import io.odysz.transact.sql.parts.Colname;
import io.odysz.transact.sql.parts.Tabl;
import io.odysz.transact.sql.parts.condition.ExprPart;
import io.odysz.transact.x.TransException;

/**The SET clause equetions' list:
* col= v1, c2 = 'v2', ...
* This class use {@link SetValue} as element type. * @author [email protected] */ public class SetList extends AbsPart { private ArrayList nvs; public SetList(ArrayList nvs) { this.nvs = nvs; } private Tabl tabl; /**These values are set value to tabl.col.
* Some times this information is used for handling expression, * like {@link io.odysz.transact.sql.parts.condition.Funcall.Func#extFile extFile} * will use this to handle external file at committing succeed. * @param table * @return this */ public SetList setVal2(Tabl table) { this.tabl = table; return this; } @Override public String sql(ISemantext context) { if (nvs == null) return ""; else return nvs.stream().map(nv -> { String s = Stream.of( // new ExprPart((String) nv[0]), new ExprPart("="), Colname.parseFullname((String) nv[0]), new ExprPart("="), new SetValue(nv[1]).setVal2(tabl, (String) nv[0])) .map(m -> { try { return m.sql(context); } catch (TransException e) { e.printStackTrace(); return ""; } }).collect(Collectors.joining("")); return s; }).collect(Collectors.joining(", ")); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy