Basically I've this interface from Material-UI docs while implementing CustomTablePaginationAction component
Material-UI CustomTablePaginationAction
interface TablePaginationActionsProps {
count: number;
page: number;
rowsPerPage: number;
onChangePage: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
}
The thing is if I want to add on this props interface like below
onChangePage: (event: React.MouseEvent<HTMLButtonElement> | React.ChangeEvent<unknown>, newPage: number) => void;
It gets me an error, like I can't modify/override the prop type.
Another question: why event object is a major param and needs to be passed all over? my codebase doesn't depend or need it.
No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } & Pick<TableCellProps, "onError" | "ref" | "abbr" | "slot" | "style" | "title" | "hidden" | "children" | "size" | ... 257 more ... | "variant"> & { ...; } & CommonProps<...> & Pick<...>): Element', gave the following error.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type '"object" | "big" | "small" | "sub" | "sup" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | ... 61 more ... | undefined'.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type 'FunctionComponent<TablePaginationActionsProps>'.
Types of parameters 'props' and 'props' are incompatible.
Type 'PropsWithChildren<TablePaginationActionsProps>' is not assignable to type 'ITablePaginationActionsProps'.
Types of property 'onChangePage' are incompatible.
Type '(event: MouseEvent<HTMLButtonElement, MouseEvent> | null, page: number) => void' is not assignable to type '(event?: MouseEvent<HTMLButtonElement, MouseEvent> | ChangeEvent<unknown> | undefined, currentPage?: number | undefined) => void'.
Types of parameters 'event' and 'event' are incompatible.
Type 'MouseEvent<HTMLButtonElement, MouseEvent> | ChangeEvent<unknown> | undefined' is not assignable to type 'MouseEvent<HTMLButtonElement, MouseEvent> | null'.
Type 'undefined' is not assignable to type 'MouseEvent<HTMLButtonElement, MouseEvent> | null'.
Overload 2 of 2, '(props: DefaultComponentProps<TablePaginationTypeMap<{}, ComponentType<Pick<TableCellProps, "onError" | "ref" | "abbr" | "slot" | "style" | "title" | "hidden" | "children" | "size" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | ... 254 more ... | "variant">>>>): Element', gave the following error.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type '"object" | "big" | "small" | "sub" | "sup" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | ... 61 more ... | undefined'.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type 'FunctionComponent<TablePaginationActionsProps>'.
Related
I'm trying to update a column from a varchar type column into a JSON but the column is already filled in with varchars how can I cast them to turn into a JSON with additional information.
Table structure with data:
-----+--------+
| id | value |
+-----+--------+
| 1 | value1 |
| 2 | value2 |
| 3 | value3 |
| 4 | value4 |
| 5 | value5 |
| 6 | value6 |
+-----+--------*
Expected Result:
+-----+----------------------------------+
| id | value |
+-----+----------------------------------+
| 1 | {"t1": "val", "value": "value1"} |
| 2 | {"t1": "val", "value": "value2"} |
| 3 | {"t1": "val", "value": "value3"} |
| 4 | {"t1": "val", "value": "value4"} |
| 5 | {"t1": "val", "value": "value5"} |
| 6 | {"t1": "val", "value": "value5"} |
+-----+----------------------------------*
Kindly help me to resolve this query
demo:db<>fiddle
When altering a column type you can add an expression to convert the data from the old type into the new one. You have to add the USING clause in order to do so:
ALTER TABLE mytable
ALTER COLUMN "value" TYPE json USING json_build_object('t1', 'val', 'value', "value");
In this case use the json_build_object() function to create the expected JSON object incl. the old value
I have this data in my feature in cucumber :
| deal | mir | stp1 | stp2 | date | mnt |
| 1255 | 120 | 1 | 1 | 2018-01-01 | 120 |
that I read in that case class
case class test1 (deal : String, mir: String, stp1:String, stp2: String, date: Sttring, mnt:Option[String])
in my step definition I read it like that :
Given("""^I have this data$""") {dt: DataTable =>
val dt_lists = dt.asList(classOf[test1 ])
}
Problem : when I put "mnt" which is Option[String] in my data like that :
| deal | mir | stp1 | stp2 | date | mnt |
| 1255 | 120 | 1 | 1 | 2018-01-01 | 120 |
I have an error : cucumber.runtime.CucumberException: cucumber.deps.com.thoughtworks.xstream.converters.ConversionException: Cannot construct scala.Option : scala.Option : Cannot construct scala.Option
when I retrieve "mnt" from the data:
| deal | mir | stp1 | stp2 | date |
| 1255 | 120 | 1 | 1 | 2018-01-01 |
in that case the program works.
any help is welcome thanks
I'm surprised why you want to convert dataTable to case class. If you are intended to use each field you can do something like this
`
Then("""^tGiven("""^I have this data$""") { (fieldNames: DataTable) =>
fieldNames.asList(classOf[String]).asScala.foreach { fieldName =>
// you will have all the field names here like deal,mir ,stp1 ,stp2,date,mnt
}
}
Here's the code to produce this error:
build.sbt
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"ai.x" %% "safe" % "0.1.0"
)
scalacOptions := Seq("-Ytyper-debug") // Only add this if you want to see a bunch of stuff
test.scala
import ai.x.safe._
package object foo {
final implicit val (enc, dec) = {
("x" === "y") -> 0
}
}
Attempting to compile this will cause this error:
[info] Compiling 1 Scala source to /tmp/test/target/scala-2.11/classes...
[error] /tmp/test/test.scala:4: recursive value x$1 needs type
[error] final implicit val (enc, dec) = {
[error] ^
[error] one error found
With the full debug mode on I can see that it's trying to resolve === and the compiler is looking at the current implicits to determine if any match. Since (enc, dec) are implicit it appears to use them as well, and so it tries to type them, causing this implicit recursion the compiler is complaining about.
| | | | | |-- "x".$eq$eq$eq("y") EXPRmode-POLYmode-QUALmode (silent: value x$1 in package)
| | | | | | |-- "x".$eq$eq$eq BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value x$1 in package)
| | | | | | | |-- "x" EXPRmode-POLYmode-QUALmode (silent: value x$1 in package)
| | | | | | | | \-> String("x")
| | | | | | | |-- x$1._1 EXPRmode (site: value enc in package)
| | | | | | | | |-- x$1 EXPRmode-POLYmode-QUALmode (site: value enc in package)
| | | | | | | | | caught scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving value x$1: while typing x$1
[error] /tmp/test/test.scala:4: recursive value x$1 needs type
[error] final implicit val (enc, dec) = {
[error] ^
| | | | | | | | | \-> <error>
| | | | | | | | \-> <error>
| | | | | | | |-- x$1._2 EXPRmode (site: value dec in package)
| | | | | | | | |-- x$1 EXPRmode-POLYmode-QUALmode (site: value dec in package)
| | | | | | | | | \-> <error>
| | | | | | | | \-> <error>
| | | | | | | |-- SafeEquals BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value x$1 in package) implicits disabled
| | | | | | | | |-- ai.x.safe.`package` EXPRmode-POLYmode-QUALmode (silent: value x$1 in package) implicits disabled
| | | | | | | | | \-> ai.x.safe.type
| | | | | | | | \-> ai.x.safe.SafeEquals.type <and> [T](l: T)ai.x.safe.SafeEquals[T]
| | | | | | | solving for (T: ?T)
| | | | | | | solving for (T: ?T)
| | | | | | | solving for (T: ?T)
| | | | | | | [adapt] SafeEquals adapted to [T](l: T)ai.x.safe.package.SafeEquals[T] based on pt String("x") => ?{def ===: ?}
| | | | | | | |-- [T](l: T)ai.x.safe.package.SafeEquals[T] EXPRmode-POLYmode-QUALmode (silent: value x$1 in package)
| | | | | | | | \-> ai.x.safe.package.SafeEquals[String]
| | | | | | | |-- ai.x.safe.`package`.SafeEquals[String]("x").$eq$eq$eq BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value x$1 in package)
| | | | | | | | \-> (r: String)Boolean
| | | | | | | \-> (r: String)Boolean
| | | | | | |-- "y" : pt=String BYVALmode-EXPRmode (silent: value x$1 in package)
| | | | | | | \-> String("y")
| | | | | | \-> Boolean
I can of course make it compile by doing something like this:
final val (x,y) = {
("x" === "y") -> 0
}
implicit val (f,b) = (x,y)
Since the implicits don't exist when the body of {} is being defined, they don't interfere with the compilers implicit search when locating that === from SafeEquals can apply to String and make the code work. Now I don't really have a problem with this because it does make sense since one can define lazy recursive serializers and other implicit things that use themselves without problems. So of course the compiler should look at the implicit that's being defined as a possible application to make something work.
But the weird thing to me is that this works if you don't extract the tuple directly during the assignment:
final implicit val tuple = {
("x" === "y") -> 0
}
Obviously that's not what I want to do since I want both things in the tuple to be implicit, (in my real case it's an encoder/decoder pair from circe). But it's just strange to me that the use of (what I believe to be) an extractor for the Tuple2 causes this compiler error with the implicit being searched. Can anyone tell me why this happens or what's causing the behavior? I'd be interested to know a bit more about what I'm seeing in the debug output. Why does resolving the type of each individual thing inside of the tuple cause the compiler error, but resolving the type of the overall tuple not cause any problems?
I have an aggregate table that needs to be updated frequently from a table that is generated by new data every few hours. Since
the aggregate table grows a lot every update, I need an efficient way to update the aggregate table.
Can someone please show me how to merge information from a new table to an aggregate table as shown below?
For example
val aggregate_table = Seq(("A", 10),("B", 20),("C", 30),("D", 40)).toDF("id", "total")
| id | total |
|-----+-------|
| "A" | 10 |
| "B" | 20 |
| "C" | 30 |
| "D" | 40 |
val new_info_table = Seq(("X"),("B"),("C"),("B"),("A"),("A"),("C"),("B")).toDF("id")
| id |
|-----|
| "X" |
| "B" |
| "C" |
| "B" |
| "A" |
| "A" |
| "C" |
| "B" |
Resulting aggregate_table after aggregate_table has been merged with
new_info_table
aggregate_table
| id | total |
|-----+-------|
| "A" | 12 |
| "B" | 23 |
| "C" | 33 |
| "D" | 40 |
| "X" | 1 |
I was experimenting with inheritance with 2.1.16 and noticed when ALTER PROPERTY is used on a child class to alter an inherited property, the schema is altered for the superclass and all descendants of that superclass. In the following example, B extends A. C extends A. B alters mandatory/notnull for a property inherited from A. The schema change impacts A, B, and C.
Is this the expected behavior for altering inherited properties (at least as far as mandatory/notnull are concerned)? If so, is there an approach for making child classes more/less restrictive or is it intentional the class schema will be identical across all inherited child classes?
Result below is identical regardless of whether A is abstract or not.
CREATE CLASS A Extends V ABSTRACT;
CREATE PROPERTY A.Name STRING;
CREATE PROPERTY A.Description STRING;
CREATE CLASS B Extends A ;
ALTER PROPERTY B.Name MANDATORY TRUE;
ALTER PROPERTY B.Name NOTNULL TRUE;
CREATE CLASS C Extends A ;
CREATE VERTEX C CONTENT { "Description": "Hello" };
Yields the following message even though C extends A, not B:
The field 'A.Name' is mandatory, but not found on record: C{Description:Hello}
with class properties showing mandatory/notnull true for all three Name properties:
CLASS 'A'...
PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
NAME | TYPE | LINKED TYPE/CLASS | MANDATORY | READONLY | NOT NULL | MIN | MAX | COLLATE |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
Name | STRING | null | true | false | true | | | default |
Description | STRING | null | false | false | false | | | default |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
orientdb {db=AdvRepos}> info class B
CLASS 'B'...
PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
NAME | TYPE | LINKED TYPE/CLASS | MANDATORY | READONLY | NOT NULL | MIN | MAX | COLLATE |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
Name | STRING | null | true | false | true | | | default |
Description | STRING | null | false | false | false | | | default |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
orientdb {db=AdvRepos}> info class C
CLASS 'C'...
PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
NAME | TYPE | LINKED TYPE/CLASS | MANDATORY | READONLY | NOT NULL | MIN | MAX | COLLATE |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
Name | STRING | null | true | false | true | | | default |
Description | STRING | null | false | false | false | | | default |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+